Support DispatcherQueueSynchronizationContext.Send.#1078
Open
jlaanstra wants to merge 2 commits intomicrosoft:masterfrom
Open
Support DispatcherQueueSynchronizationContext.Send.#1078jlaanstra wants to merge 2 commits intomicrosoft:masterfrom
jlaanstra wants to merge 2 commits intomicrosoft:masterfrom
Conversation
3024806 to
7e8bc5c
Compare
Contributor
|
@manodasanW Any chance to get this PR merged? |
| m.Set(); | ||
| } | ||
| }); | ||
| m.WaitOne(); |
There was a problem hiding this comment.
I'm not sure the Send method is allowed to block until the callback runs; it can lead to deadlocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In various places in .NET, the runtime calls SynchronizationContext.Send. For example in the SystemEvents class Send is used: https://github.com/dotnet/runtime/blob/6de7147b9266d7730b0d73ba67632b0c198cb11e/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs#L1326
This means that subscribing to events on the SystemEvents class from the UI thread in a WinUI3 app works, but the event is never fired, because Send throws an exception. There are likely other places where Send is used and where this causes problems for WinUI3 apps.
This PR adds support for Send in a similar to how Xamarin Android does this for the Android main thread: https://github.com/xamarin/xamarin-android/blob/main/src/Mono.Android/Android.App/SyncContext.cs and MAUI for GtkSynchronizationContext: https://github.com/dotnet/maui/blob/18e0f4ebbcca7c904ccdb67e6439cb72382e2a40/src/Compatibility/Core/src/GTK/GtkSynchronizationContext.cs