在其他线程中访问UI线程

来源:互联网 发布:windows latex 实时 编辑:程序博客网 时间:2024/06/02 08:03

在WPF中,示例代码如下:

this.Dispatcher.BeginInvoke(newAction(() =>{

 

           

           

                    if (sensor == (char)1)

 

                     {

                            xxx.Text = x.ToString();

                            yyy.Text = y.ToString();

                            zzz.Text = z.ToString();

                     }

            }));

在Metro中,示例代码如下:

Dispatcher.InvokeAsync(CoreDispatcherPriority.Normal, (object obj, InvokedHandlerArgs args) =>

 

                   {

                       OutputText.Text = mb.channel_str;

                      //System.Diagnostics.Debug.WriteLine("Test Replace!!!!!!!!!!!!!!!");

 

                   }, OutputText.Text,null);

 


推荐一个资源,不错:

http://www.cnblogs.com/mgen/archive/2012/03/10/2389509.html


原创粉丝点击