Given
Action closeLoadingAction = new Action(() =>
{
loadingForm.Close();
#region - may need to put into second Action
panelOnMainForm.Controls.AddRange(physdocControls.ToList<Control>().ToArray());
if (Handle != IntPtr.Zero)
User32DLL.SetForegroundWindow(this.Handle);//Handle is a property of the mainForm.
#endregion
});
Sometimes I get handle not created exceptions even though I check the Invoke required.
if(loadingForm.InvokeRequired)
loadingForm.Invoke(closeLoadingAction);
else
closeLoadingAction();
The loading form runs on the same thread as the main form. The code you see above runs in a seperate thread. I suspect that I need another check for invoke against the main form. Do I need a second check or is what I have already safe?