2015-09-18 142 views
1

我想实现一个全局异常处理程序,当下面一行产生一个错误,它只是停止在调试器中出现问题。全局异常处理程序WPF

var list = await _repository.GetAllAsync<ContactView>(); 

Application.Current.DispatcherUnhandledException += 
      new DispatcherUnhandledExceptionEventHandler(MainThreadExceptionHandler); 
AppDomain.CurrentDomain.UnhandledException += 
      new UnhandledExceptionEventHandler(DomainExceptionHandler); 

回答

1

尝试挂钩到TaskScheduler.UnobservedTaskException如下:

TaskScheduler.UnobservedTaskException += (sender, eventArgs) => 
{ 
    ... 
};