0

我正在使用它来将文本写回textbox1,并且它可以正常工作以避免跨线程操作,但是......我只收到一行输出。知道如何进行更多的AppendText通话而不是基本的短信通话吗?

  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;
        }
    }
4

1 回答 1

1
 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
     {
         //append  text  like  this  
         this.textBox1.Text += text;
     }
}
于 2013-11-19T21:20:32.383 回答