add handling for SynchronizationContext
This commit is contained in:
parent
c1c9d86ff7
commit
43357a5198
@ -35,7 +35,16 @@ namespace ObservableCollections
|
||||
|
||||
public void Post(CollectionEventDispatcherEventArgs ev)
|
||||
{
|
||||
synchronizationContext.Post(callback, 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