private bool HandleException(Exception exception) { if (UnhandledException == null) { return(false); } var exWrapper = new AysncUnhandledExceptionEventArgs { Exception = exception }; UnhandledException(this, exWrapper); #if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } #endif return(exWrapper.Handled); }
private async void SynchronizationContextUnhandledException(object sender, AysncUnhandledExceptionEventArgs e) { e.Handled = true; if (e.Exception.Message.Contains("404")) { await GalaSoft.MvvmLight.Threading.DispatcherHelper.RunAsync(async () => { await new MessageDialog(App.Current.Resources["ErrorCode_404"].ToString()).ShowAsync(); }); } else if(e.Exception.Message.Contains("A task was canceled")) { } else { await GalaSoft.MvvmLight.Threading.DispatcherHelper.RunAsync(async () => { await new MessageDialog("异步线程出错:\r\n" + e.Exception.Message).ShowAsync(); }); } }
private bool HandleException(Exception exception) { if (UnhandledException == null) { return false; } var exWrapper = new AysncUnhandledExceptionEventArgs { Exception = exception }; UnhandledException(this, exWrapper); #if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } #endif return exWrapper.Handled; }