internal void Invoke() { try { Dispatcher.InvokeDelegate(d, args); } catch (TargetInvocationException tie) { // the unhandled exception is the inner exception, not the TargetInvocationException Application.OnUnhandledException(this, tie.InnerException); } catch (Exception ex) { Application.OnUnhandledException(this, ex); } }