Rising

自我学习记录,方便使用时查找。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在多线程环境中,有时线程不能直接更新界面,那么可以采用以下方法进行:

void threadFunction()

{

    Action<string> act = delegate(string s)

    {

        label1.Content = s;

    };

     // 通过Dispatcher调用上面定义的委托完成界面更新,设置label1中显示的内容。

     this.Dispatcher.BeginInvoke(act, "message");
}

posted on 2011-12-17 10:33  Rising  阅读(312)  评论(0编辑  收藏  举报