在本文中:
http://msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx
作者使用以下方法对 Windows 窗体控件进行线程安全调用:
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;
}
}
有没有更短的方法来完成同样的事情?