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();