Exemplo n.º 1
0
        private void WindowX_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var result = MessageBoxX.Show("是否退出程序", "警告", Application.Current.MainWindow, MessageBoxButton.YesNo, new MessageBoxXConfigurations()
            {
                MessageBoxStyle = MessageBoxStyle.Standard,
                MessageBoxIcon  = MessageBoxIcon.Warning
            });

            if (result == MessageBoxResult.Yes || result == MessageBoxResult.OK)
            {
                ADS.BeforeClose();
                System.Environment.Exit(0);
            }
            else
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 2
0
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            if (log == null)
            {
                log = new Log("app_error");
            }
            ADS.BeforeClose();
            //处理完后,需要将 Handler = true 表示已处理过此异常
            e.Handled = true;
            log.LOG(e.Exception.Message + e.Exception.StackTrace);

            if (WindowCommon.ConfirmAction("是否重启,发现异常:\n" + e.Exception.Message + e.Exception.StackTrace))
            {
                //////开启新的实例
                System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath);
            }

            //////关闭当前实例
            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
Exemplo n.º 3
0
        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            //可以记录日志并转向错误bug窗口友好提示用户
            if (e.ExceptionObject is System.Exception)
            {
                if (log == null)
                {
                    log = new Log("app_error");
                }
                Exception ex = (System.Exception)e.ExceptionObject;
                log.LOG(ex.Message + ex.StackTrace);
                ADS.BeforeClose();

                if (WindowCommon.ConfirmAction("是否重启,发现异常:\n" + ex.Message + ex.Source))
                {
                    //////开启新的实例
                    System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath);
                }

                //////关闭当前实例
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }