Added: This article[^] has some interesting stuff about potential bugs with InvokeRequired
- worth a read!
This comes up time and again.
Luc[^] has a great article explaining all here[^].
For those just wanting the solution...
public void WithParameterMethod(int parameter)
{
if (InvokeRequired)
Invoke(new MethodInvoker(
delegate
{
WithParameterMethod(parameter);
}
));
else
{
}
}
public void NoParameterMethod()
{
if (InvokeRequired)
Invoke(new MethodInvoker(
NoParameterMethod
));
else
{
}
}