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