Just because you call Invoke
, it doesn't stop execution of the current method. A quick and simple solution is to simply return
after calling Invoke
:
delegate void ManualCurtainShuttoffHandler();
public void ManualCurtainShutoff()
{
if (InvokeRequired)
{
Invoke(new ManualCurtainShuttoffHandler(ManualCurtainShutoff));
return;
}
// ACTION: Disable check boxes
}
This will skip the rest of the execution of ManualCurtainShutoff
that's running on the background thread while still promoting a new execution of the method on the main thread.