把开发过程经常用的内容记录起来,下面的代码是关于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# WPF中多线程调用窗体组件的代码
最新推荐文章于 2023-02-27 21:30:34 发布