C# 线程操作窗体

来源:互联网 发布:photoshop7软件下载 编辑:程序博客网 时间:2024/05/16 05:54
 

delegate void SetTextCallback(string text);

          private void SetText(string text)

          {

              // InvokeRequired required compares the thread ID of the

              // calling thread to the thread ID of the creating thread.

              // If these threads are different, it returns true.

              if (this.textBox1.InvokeRequired)

              {

                  SetTextCallback d = new SetTextCallback(SetText);

                  this.Invoke(d, new object[] { text });

              }

              else

              {

                  this.textBox1.Text = text;

              }

          }

 

SetText(time.ToString());

原创粉丝点击