I'm using this small utility function:
public static void Invoke(Control control, Action method)
{
if (control.InvokeRequired)
{
if (control.IsDisposed || !control.IsHandleCreated || !control.Created)
return;
control.Invoke(method);
}
else
method();
}
Despite all of those sanity checks, when I close my application, a stray invoke always produces this error:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
This, despite there clearly being a check to see if the handle is created... What else can I do?