private void timer_Elapsed(object sender, ElapsedEventArgs e) { if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.BeginInvoke(new EventHandler <ElapsedEventArgs>(timer_Elapsed), sender, e); return; } // Update list box ListBox.Items.Clear(); foreach (var p in Process.GetProcessesByName(_procName)) { if (!string.IsNullOrEmpty(p.MainWindowTitle)) { ListBox.Items.Add(p.MainWindowTitle); } } // Check if process is running if (MiscFunctions.IsProcessRunning(_procName)) { return; } DialogResult = true; Close(); }
internal static bool?DisplayRunningMsg(string scannerName, string procName) { if (Application.Current.Dispatcher.Thread != Thread.CurrentThread) { return ((bool?) Application.Current.Dispatcher.Invoke(new Func <string, string, bool?>(DisplayRunningMsg), scannerName, procName)); } if (!MiscFunctions.IsProcessRunning(procName)) { return(true); } if (Settings.Default.privacyCleanerAutoSkipScanner) { MessageBox.Show(Application.Current.MainWindow, $"Automatically skipping the scanning for {scannerName}...", Utils.ProductName, MessageBoxButton.OK, MessageBoxImage.Information); return(false); } var dlgResult = new RunningMsg(scannerName, procName); return(dlgResult.ShowDialog()); }