-
Notifications
You must be signed in to change notification settings - Fork 700
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
Fix: The synchronization context method Send is now blocking #1854
Conversation
The send method of the synchronization context has to block the caller thread in case it is not the main thread.
Hi. Thanks for this. Can you please explain what issue this fixes and how it fixes it? |
Sure. The current "send" method implementation of the synchronization context is in fact equal to the "post" method. It does enqueue/dispatch the action in the idle handler of the main loop. The changes: The send method waits until the action is executed in the main thread/loop and blocks the caller until done. There is a differentation between a call from the main thread and a "non"-main thread. To differentiate the main thread the main thread id is being stored during the .Init call. My use/case is the following:
|
Is it worth making the blocking optional? I know winforms has |
I never hit the Send method on a breakpoint in the GUI.cs. The Post method yes I hit in a breakpoint on async/await. |
I'm confused. @saskathex pointed out in his response that right now
...and therefore the blocking/non-blocking behavior IS optional. Right? Regardless, there's a merge error now AND a real need for unit tests. |
@saskathex - can you please chime in here? |
Imo making the blocking optional is not way to go. The synchronization context Post/Send methods are generic over all ui frameworks and should be used the correct way. The current implementation is incorrect and should be fixed. |
Thanks for your feedback. I already tried to get the Send method to be called in the By the way you have to resolve the conflicts for this been merged. |
Sorry for confusing things, I think I was confusing Post/Send with |
… saskathex-patch-send
I will try to add some unit tests. |
Send has to invoke the action instantly instead of enqueuing in case of main thread call.
Thank you for the unit tests, great. Can you also provide a unit test for the |
Thanks @saskathex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great work. Thank you!
Is this PR good to go now? Can I merge it? |
For me yes. |
The send method of the synchronization context has to block the caller thread in case it is not the main thread.