Пример #1
0
 private static void Main(string[] args)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Program.SetCulture();
     ThreadException.SettingUpForm();
     if (Program.CFG.GetConfig("FirstRun", true))
     {
         FunctionalForm.Infomation(SR.NotGreenWareWarning);
         Program.CFG.SetConfig("FirstRun", false);
     }
     if (args != null && args.Length == 3)
     {
         if (args[0] == "-replace")
         {
             RunReplaceTask mainForm = new RunReplaceTask
             {
                 ForceKillAllNonSysProcess = (args[1] == "1"),
                 ParentProcessID           = int.Parse(args[2])
             };
             Application.Run(mainForm);
             return;
         }
     }
     else
     {
         MainForm mainForm2 = new MainForm();
         string   text      = Application.StartupPath + "\\source";
         if (Directory.Exists(text))
         {
             mainForm2.SourceDic = text;
         }
         Application.Run(mainForm2);
     }
 }
Пример #2
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)
                }
            }
        }
Пример #3
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));
     }
 }
Пример #4
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 { }
        }
Пример #5
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);
        }
Пример #6
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)
            {
            }
        }
Пример #7
0
 protected virtual void OnThreadException(object exceptionObject)
 {
     ThreadException?.Invoke(this, new UnhandledExceptionEventArgs(exceptionObject, false));
 }
Пример #8
0
 private void Start()
 {
     thread = new ThreadException();
     thread.Start();
 }
Пример #9
0
 protected virtual void AddException(Exception ex)
 {
     WithLock(() => _exceptions.Add(ex));
     ThreadException?.Invoke(this, new ThreadExceptionEventArgs(ex));
 }