//后台线程更新TextBox
 private void SetTextBox(TextBox txt, string value)
        {
            Action act = () =>
                {
                    txt.Text = value;
                };
            if (txt.InvokeRequired)
            {
                txt.Invoke(act);
            }
            else
            {
                act();
            }
        }

 private void TestThread()
        {
            int i = 0;
            while (true)
            {
                Thread.Sleep(1000);
                i++;
                SetTextBox(textBox2,i.ToString());
            }
        }

  

相关文章:

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