线程间操作无效: 从不是创建控件“richTextBox1”的线程访问它。
这个错误需要一个委托来解决
private delegate void SetRichText(string txt,bool b);
private void SetText(string txt,bool b)
{
if (richTextBox1.InvokeRequired)
{
SetRichText srt = new SetRichText(SetText);
this.Invoke(srt, new object[] { txt,b });
}
else
{
if (b)
richTextBox1.Text += txt + "\n";
else
richTextBox2.Text += txt + "\n";
}
}