Process[] processes = Process.GetProcesses(); foreach (Process process in processes) { Console.WriteLine("Process Name: " + process.ProcessName); Console.WriteLine("Memory Usage: " + process.WorkingSet64 + " bytes"); }
Process process = Process.GetProcessesByName("chrome")[0]; while (!process.HasExited) { Console.WriteLine("CPU Usage: " + process.TotalProcessorTime); Console.WriteLine("Memory Usage: " + process.WorkingSet64 + " bytes"); Thread.Sleep(1000); }This example monitors the performance of a specific process (in this case, Google Chrome) in real-time by continuously printing its CPU usage and memory usage. In conclusion, System Peek is a useful tool for debugging and monitoring running processes in C#. It is included in the .NET framework, so you don't have to download anything extra to use it.