Merge pull request #83 from zerodev1200/fix-synccontext-thread-handling
Improve synchronization handling in event dispatcher
This commit is contained in:
commit
a4d80bda85
@ -35,8 +35,17 @@ namespace ObservableCollections
|
||||
|
||||
public void Post(CollectionEventDispatcherEventArgs ev)
|
||||
{
|
||||
if (SynchronizationContext.Current == null)
|
||||
{
|
||||
// non-UI thread, post the event asynchronously
|
||||
synchronizationContext.Post(callback, ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
// UI thread, send the event synchronously
|
||||
synchronizationContext.Send(callback, ev);
|
||||
}
|
||||
}
|
||||
|
||||
static void SendOrPostCallback(object? state)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user