using System.Diagnostics; Process[] processes = Process.GetProcesses(); foreach (Process process in processes) { Console.WriteLine($"Name: {process.ProcessName} | PID: {process.Id} " + $"| Memory: {process.WorkingSet64 / 1024} KB"); }
using System.Diagnostics; bool isRunning = false; foreach (Process process in Process.GetProcesses()) { if (process.ProcessName.Equals("notepad", StringComparison.OrdinalIgnoreCase)) { isRunning = true; break; } } if (isRunning) Console.WriteLine("Notepad is running"); else Console.WriteLine("Notepad is not running");This example shows how to use the RunningApp Query library to check if a specific application (in this case, Notepad) is running. Package Library: System.Diagnostics.Process namespace.