2013年(21)
分类: C#/.net
2013-07-05 12:38:20
点击(此处)折叠或打开
点击(此处)折叠或打开
SynchronizationContext.Current可能返回的是null,除非你在用前设置过该值。
However, it is possible that the SynchronizationContext.Current might just return null, unless you have explicitly set it before usage.
Dispatcher.CurrentDispatcher,根据当前运行的线程决定他的值,如果当前线程是主线程,那么Dispatcher.Current返回的是UI dispatcher,如果该线程是从背景线程中过来,那么Dispatcher可能会被派遣到其他的背景线程 。
The Dispatcher.CurrentDispatcher, which will depends on the currently running thread, if the thread is the main UI thread, then the Dispatcher.Current get the main UI dispatcher, while if you are running from a background , you will probably get a dispatcher where dispatching goes to another (maybe the same) thread.