本文实例讲述了C#中WPF使用多线程调用窗体组件的方法。分享给大家供大家参考。具体如下:
Thread thread=new Thread(new ThreadStart(TestThread));
thread.Start();
private void TestThread()
{
for (int i = 0; i < 11;i++ )
{
Thread.Sleep(2000);
this.listBox1.Dispatcher.Invoke(new Action(() => { this.listBox1.Items.Add("this is a test!!!"); }));
}
}
希望本文所述对大家的C#程序设计有所帮助。