diff --git a/src/ObservableCollections/ICollectionEventDispatcher.cs b/src/ObservableCollections/ICollectionEventDispatcher.cs index c2ccfa0..049f580 100644 --- a/src/ObservableCollections/ICollectionEventDispatcher.cs +++ b/src/ObservableCollections/ICollectionEventDispatcher.cs @@ -35,7 +35,16 @@ public SynchronizationContextCollectionEventDispatcher(SynchronizationContext sy 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)