-
Notifications
You must be signed in to change notification settings< 8000 /tool-tip> - Fork 1.2k
Dispatcher.Invoke() blocks Parallel.For execution on .NET 7 #8066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If you get into deadlock, things hang, that is expected. Your UI update practice is bad and it does not make sense, because the value of Use |
Yes, that makes sense, I should not block the dispatcher with many UI updates if the previous one is not completed. |
Just wanted to share a small demo confirming that replacing I also added Here's the test project: Hope it's helpful for future reference. |
@0xfa11b4c Thank you. And could you try the |
@lindexi |
Tested with .NET 8 using Code and logs are in the repo. |
@0xfa11b4c Thank you very much. And I think it is reasonable to use |
Description
When an Invoke() is called to update a UI object in the handler of a Threading.Timer, the execution of a simple Parallel.For gets stuck.
I report here this issue previously opened in dotnet/runtime because they said it's not a problem with the Paralle.For
I know I should avoid running a Parallel.For on the UI thread, but I think the execution should not hang.
Reproduction Steps
Here is a small WPF sample to reproduce the issue:
Expected behavior
Parallel.For doesn't hang or slow down
Actual behavior
Parallel.For hangs
Regression?
The same application on .NET Framework doesn't produce so bad performance, the Parallel.For take about 150ms
On .NET 6 the Parallel.For take about 2 seconds but it doesn't stuck.
Known Workarounds
No response
Impact
No response
Configuration
.NET 7
Windows 11 version 21H2
Other information
No response
The text was updated successfully, but these errors were encountered: