private void button3_Click(object sender, EventArgs e)
        {
            RunAsync(() =>
            {
                // Just loop.
                int ctr = 0;
                for (ctr = 0; ctr <= 10; ctr++)
                {
                    Thread.Sleep(2000);
                    RunInMainthread(() =>
                    {
                        textBox1.Text = ctr.ToString();
                    });
                }
              
            });
           
            MessageBox.Show("");
        }  // 异步线程
        public static void RunAsync(Action action)
        {
            ((Action)(delegate()
            {
                action.Invoke();
            })).BeginInvoke(null, null);
        }
        public void RunInMainthread(Action action)
        {
            this.BeginInvoke((Action)(delegate()
            {
                action.Invoke();
            }));
        }

相关文章:

  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2022-01-12
  • 2021-06-26
  • 2022-12-23
  • 2022-01-12
  • 2021-12-25
  • 2021-12-05
  • 2022-12-23
相关资源
相似解决方案