, , - , , , InvokeRequired , re-Invoke() , , , . , InvokeRequired ( , / ); - , Load(), Closing(), , , .
( BackgroundWorkers, TPL-, BeginInvoke() Start() ), . InvokeRequired ( - , WinAPI GetThreadId GetWindowThreadProcessId ), , , , :
public void MyWindowMethod()
{
if(InvokeRequired)
this.Invoke(new Action(MyWindowMethod));
else
{
}
}
public void MyWindowMethod2(string input)
{
if(InvokeRequired)
this.Invoke(new Action<string>(MyWindowMethod2), input);
else
{
}
}
public string MyWindowMethod3(string input)
{
if(InvokeRequired)
return (string)(this.Invoke(new Func<string, string>(MyWindowMethod3), input));
}