c# 跨线程调用控件的方法

//WinForm用法
Thread thread = new Thread(p=> { Action action = new Action(() => { System.Windows.Forms.MessageBox.Show("test"); }); action.Invoke(); }); thread.IsBackground = true; thread.Start();
//WPF用法
Thread thread = new Thread(p=> {

            this.Dispatcher.Invoke(new Action(delegate {System.Windows.Forms.MessageBox.Show("test");}));

                });
                thread.IsBackground = true;
                thread.Start();
 

 

posted @ 2016-06-22 17:09  IsCarrie  阅读(807)  评论(0编辑  收藏  举报