- Use the Dispatcher when your code is tightly coupled to WPF.
- Use the AsyncOperationManager when you need to queue something on the 'Context' thread. This works with Windows Forms, ASP .NET and WCF applications as well.
- Avoid using the SynchronizationContext yourself. The AsyncOperationManager uses this mechanism internally.
SynchronizationContext.Current object is of type DispatcherSynchronizationContext which is actually just a wrapper around the Dispatcher object and the Post and Send methods just delegate to Dispatcher.BeginInvoke and Dispatcher.Invoke.
So even if you decide to use SynchronizationContext I think you end up calling dispatcher behind the scenes.
Besides, supposedly, it is a bit cumbersome to use SynchronizationContext as you have to pass a reference to the current context to all threads that need to call into your UI.
0 коммент.:
Post a Comment