zoukankan      html  css  js  c++  java
  • wpf 全局异常捕获处理

    /// <summary>
        /// App.xaml 的交互逻辑
        /// </summary>
        public partial class App : Application
        {
            private const string Tag = nameof(App);
            public App() 
            {
                Dispatcher.UnhandledException += Dispatcher_UnhandledException;
                DispatcherUnhandledException += App_DispatcherUnhandledException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                
            }
    
            private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
            {
                Logger.Fatal(Tag,"",e.Exception);
            }
    
            private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
            {
                var exception = e.ExceptionObject as Exception;
                var terminatingMessage = e.IsTerminating ? " The application is terminating." : string.Empty;
                var exceptionMessage = exception?.Message ?? "An unmanaged exception occured.";
                var message = string.Concat(exceptionMessage, terminatingMessage);
                Logger.Fatal(Tag, message, exception);
            }
    
            private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
            {
                Logger.Fatal(Tag, "", e.Exception);
            }
        }
  • 相关阅读:
    (3)常用模块
    (2)ansible主机清单文件inventory
    (1)ansible基本配置
    文件权限之facl丶文件属性丶特殊权限
    文件权限之基本权限
    用户管理
    java jvm学习笔记二(类装载器的体系结构)
    java jvm学习笔记一
    观察者模式——转
    观察者模式
  • 原文地址:https://www.cnblogs.com/akiing/p/7519112.html
Copyright © 2011-2022 走看看