示例#1
0
        private static void Process(System.Exception exception)
        {
            lock (SyncRoot) {
                System.Environment.ExitCode = unchecked ((int)0x8000ffff); //E_UNEXPECTED(0x8000ffff)

                if (exception != null)
                {
                    System.Diagnostics.Trace.TraceError(exception.ToString() + "  {Medo.Application.UnhandledCatch}");

                    System.Windows.Forms.Application.ThreadException  -= Application_ThreadException;
                    System.AppDomain.CurrentDomain.UnhandledException -= AppDomain_UnhandledException;

                    ThreadException?.Invoke(null, new ThreadExceptionEventArgs(exception));
                }

                System.Diagnostics.Trace.TraceError("Exit(E_UNEXPECTED): Unhandled exception has occurred.  {Medo.Application.UnhandledCatch}");

                if (UnhandledCatch.UseFailFast)
                {
                    System.Environment.FailFast(exception.Message);
                }
                else
                {
                    System.Environment.Exit(unchecked ((int)0x8000ffff)); //E_UNEXPECTED(0x8000ffff)
                }
            }
        }
示例#2
0
 public static void Run(Form mainForm)
 {
     // TODO: Is an Application.Run replacement required?
     try {
         // err...
     } catch (Exception e) {
         // ... what is the sender anyway?
         ThreadException?.Invoke(mainForm, new ThreadExceptionEventArgs(e));
     }
 }
示例#3
0
        /// <summary>
        /// called when a thread throws an exception
        /// </summary>
        /// <param name="ex">Exception thrown</param>
        protected void OnThreadException(Exception ex)
        {
            try
            {
                if (ex is ThreadAbortException && !ShouldReportThreadAbort)
                {
                    return;
                }

                ThreadException?.Invoke(this, ex);
            }
            catch { }
        }
示例#4
0
        private bool RaiseExceptionEvent(Exception exception)
        {
            var args = new OperationUnhandledExceptionEventArgs(exception);

            ThreadException?.Invoke(this, args);

            if (!args.Handled)
            {
                args = new OperationUnhandledExceptionEventArgs(exception);

                if (!args.Handled)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#5
0
        /// <summary>
        /// called when a thread throws an exception
        /// </summary>
        /// <param name="ex">Exception thrown</param>
        public void OnThreadException(Exception ex)
        {
            try
            {
                if (ex is ThreadAbortException && !ShouldReportThreadAbort)
                {
                    return;
                }

                if (ThreadException != null)
                {
                    ThreadException.Invoke(this, ex);
                }
            }
            catch (Exception)
            {
            }
        }
示例#6
0
 protected virtual void OnThreadException(object exceptionObject)
 {
     ThreadException?.Invoke(this, new UnhandledExceptionEventArgs(exceptionObject, false));
 }
示例#7
0
 protected virtual void AddException(Exception ex)
 {
     WithLock(() => _exceptions.Add(ex));
     ThreadException?.Invoke(this, new ThreadExceptionEventArgs(ex));
 }