In this article:
http://msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx
The author uses the following method to make thread-safe calls to a Windows For
1) Using anonymous delegate
private void SetText(string text)
{
if (this.InvokeRequired)
{
Invoke(new MethodInvoker(delegate() {
SetText(text);
}));
}
else
{
this.textBox1.Text = text;
}
}
2) AOP approach
[RunInUIThread]
private void SetText(string text)
{
this.textBox1.Text = text;
}
http://weblogs.asp.net/rosherove/archive/2007/05.aspx?PageIndex=2
3) Using lambda expressions (outlined by others).