本文實(shí)例講述了C#中WPF使用多線程調(diào)用窗體組件的方法。分享給大家供大家參考。具體如下:
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!!!"); })); }}希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選