使用委托的方法 在线程中操作winform控件
delegate void SetTextCallBack(string text);
private void addlog(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallBack stcb = new SetTextCallBack(addlog);
this.Invoke(stcb, new object[] { text});
}
else
{
this.textBox1.Text = DateTime.Now.ToLongTimeString()+" "+text;
}
}