/// <summary>
 /// 注册全局异常处理。
 /// onUnhandledException 异常处理事件,如果未null则使用DefaultExcetionHandle
 /// </summary>
 public static void RegisterGlobalException(ExceptionEventHandler onUnhandledException = null, EnumErrorHandle handle = EnumErrorHandle.Default)
 {
     _onExceptionEventHandler = onUnhandledException ?? DefaultExcetionHandle;
     _ErrorHandle             = handle;
     //AppDomain中的异常
     AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     //主UI线程
     Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
     //task scheduler
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
     //SEH
     RegisterSEHException();
 }
 private static void OnHandedExceptionProxy(Exception exception, ExceptionSources exSource, EnumErrorHandle handle)
 {
     try
     {
         var handler = _onExceptionEventHandler;
         if (handler != null)
         {
             handler(exception, handle, exSource);
         }
     }
     catch (Exception e)
     {
         HandleException(e, exSource, false);
     }
 }