开发者

How System.Windows.Threading.Dispatcher in the main UI thread is accessible from other threads?

I have read that we can not access any开发者_开发问答thing in the main UI thread in Silverlight application from other worker threads.

So why it is possible to access an object of class System.Windows.Threading.Dispatcher which is associated with the main UI thread from other worker threads when we want to delegate some work to be done on the User Interface ?

public partial class DispatcherExample : UserControl
{
  public void AnyFunctionExecutingInSomeOtherThread()
  {
    this.Dispatcher.BeginInvoke(SomeDelegate);
  }
}


A Dispatcher instance can be accessed from any thread because it does not have thread affinity. If it did have thread affinity, it would essentially be useless because its main reason for being is to dispatch messages onto the correct thread from any thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜