private void RefreshApplications() { var processes = Process.GetProcesses().Where(x => x.MainWindowHandle != IntPtr.Zero).OrderBy(x => x.ProcessName); if (RunningApplications == null) { RunningApplications = new ObservableRangeCollection <Process>(processes); } else { RunningApplications.ReplaceRange(processes); } if (!string.IsNullOrEmpty(SelectedProcessName)) { var process = processes.Where(x => x.ProcessName == SelectedProcessName); if (process != null && process.Count() == 1) { SelectedProcess = process.First(); } } }
/// <summary> /// Provides information about running applications on a PC. /// </summary> /// <returns>The titles of the main windows of running applications.</returns> private static IEnumerable <string> GetInfoAboutRunningApps() { return(RunningApplications.GetListOfRunningApps()); }