Chinaunix首页 | 论坛 | 博客
  • 博客访问: 49521
  • 博文数量: 21
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 190
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-24 15:25
文章分类

全部博文(21)

文章存档

2013年(21)

我的朋友

分类: C#/.net

2013-07-05 12:38:20


点击(此处)折叠或打开


  1.                 Dispatcher.CurrentDispatcher.BeginInvoke(
  2.                     new Action(
  3.                         () =>
  4.                         {
  5.                             // …
  6.                         ));

 

点击(此处)折叠或打开

  1. SynchronizationContext.Current.Post(new SendOrPostCallback(
  2.                                                         o =>
  3.                                                         {
  4.                                                               // …
  5.                                                         ), null);

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.



阅读(428) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~