2015-09-18 140 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) => 
{ 
    ... 
};