public async void Execute(object parameter) { // validation?? _vm.IsBusy = true; _vm.BusyMessage = "Saving your changes...."; var saveTask = Task.Run(() => SaveChanges()); try { await saveTask; foreach (var ct in _vm.Contacts.Where(a => a.IsChanged)) { ct.AcceptChanges(); } } catch (Exception ex) { MessageBox.Show("Some kind of error happened. Check the logs."); SuperLogger.WriteLog(ex, LoggingCategory.UserInterface); } _vm.IsBusy = false; }
private static void HandleUnhandledException(Exception exception) { try { SuperLogger.WriteLog(exception, LoggingCategory.UserInterface); MessageBox.Show(TechErrorMsg, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { SuperLogger.WriteLog(ex, LoggingCategory.UserInterface); MessageBox.Show(TechErrorMsg, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
protected override void OnStartup(StartupEventArgs e) { try { DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory()); Current.DispatcherUnhandledException += GlobalExceptionHandler; // set up a global exception handler for all unhandled exceptions AppDomain.CurrentDomain.UnhandledException += AppDomainExceptionHandler; base.OnStartup(e); } catch (Exception ex) { SuperLogger.WriteLog(ex, LoggingCategory.UserInterface); MessageBox.Show("Something failed starting up the application!", "Extensible Data Demo", MessageBoxButton.OK, MessageBoxImage.Exclamation); Environment.Exit(9); } }