internal void Invoke (Delegate d, params object[] args)
{
if (CheckAccess ()) {
try {
InvokeDelegate (d, args);
} catch (Exception ex) {
Application.OnUnhandledException (this, ex);
}
} else {
ManualResetEvent wait = new ManualResetEvent (false);
BeginInvoke (delegate {
try {
InvokeDelegate (d, args);
} catch (Exception ex) {
Application.OnUnhandledException (this, ex);
} finally {
wait.Set ();
}
});
wait.WaitOne ();
}
}