private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { System.Windows.MessageBox.Show("Error"); File.AppendAllText(ExceptionLogFile, "Exception:\n" + FarayanUtility.PrintException(e.Exception)); Logger.Error("General Exception", e.Exception); e.Handled = true; }
private void StartButton_Click(object sender, RoutedEventArgs e) { workerConfigs configs = new workerConfigs(); configs.LogPermittedApps = PermittedsCheckBox.IsChecked.GetValueOrDefault(); configs.LogBlockedApp = BlockedsCheckBox.IsChecked.GetValueOrDefault(); configs.LiveLog = LiveLogsCheckBox.IsChecked.GetValueOrDefault(); configs.Max = FarayanUtility.TryParseInt(MaxRecordsCountTextBox.Text).GetValueOrDefault().EnsureBetween(100, 100_000); StartButton.IsEnabled = false; PermittedsCheckBox.IsEnabled = false; BlockedsCheckBox.IsEnabled = false; LiveLogsCheckBox.IsEnabled = false; TheBackgroundWorker = new BackgroundWorker(); TheBackgroundWorker.WorkerReportsProgress = true; TheBackgroundWorker.DoWork += TheBackgroundWorker_DoWork; TheBackgroundWorker.ProgressChanged += TheBackgroundWorker_ProgressChanged; TheBackgroundWorker.RunWorkerCompleted += TheBackgroundWorker_RunWorkerCompleted; TheBackgroundWorker.RunWorkerAsync(configs); }