new Thread(() => { 
            
                //多线程处理的任务
                //调用ui进程
                //Invoke(new Action(() => { 
                BeginInvoke(new Action(() => { 
                //改变UI控件状态
                
                }));
            
            }).Start();

比如:

 new Thread(() =>
                {

                    Thread.Sleep(1000);
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < 1000; i++)
                        sb.Append("test");
                    string s = sb.ToString();
                    Stopwatch sw = Stopwatch.StartNew();
                    Invoke(new Action(() =>
                    {
                        textBox1.Text = s;
                    }));
                    MessageBox.Show(sw.ElapsedMilliseconds.ToString());  



                }).Start();

相关文章:

  • 2021-10-12
  • 2021-07-03
  • 2021-08-13
  • 2021-09-18
  • 2021-11-13
  • 2021-12-18
猜你喜欢
  • 2021-11-01
  • 2021-08-13
  • 2022-12-23
  • 2021-08-13
  • 2022-01-16
  • 2021-11-19
  • 2021-08-14
相关资源
相似解决方案