2

我已经环顾了大约 3 个小时,但无法让这个调用工作。我需要调用,因为调用它的是在不同的线程中并且说它不稳定。

这就是我所说的(我这样称呼它textBox1_TextChanged(null, null);):

 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     if(this.InvokeRequired)
     {
        this.Invoke(this?WHAT GOES HERE, null); // I know it should be a delegate or something but I can't change this to that
     }
     else
     {
        string temp = ""; 
        temp += TextToAdd;
        textBox1.Text = "s";
     }
}
4

1 回答 1

2

您可以使用BeginInvoke从其他线程更新 UI。

if (this.InvokeRequired)
{
  var action = new Action(() => textBox1.Text = "s");
  this.BeginInvoke(action);
}
于 2016-01-28T07:16:28.113 回答