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");}));this

 }); thread.IsBackground = true; thread.Start();
相關文章
相關標籤/搜索