Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Use the PerformanceCounter and Process
class.
Try to execute the following code for yourself, so that it would be more clear to you how to work with these classes further.
foreach (Process proc in Process.GetProcesses()) {
using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time", proc.ProcessName)) {
pcProcess.NextValue();
System.Threading.Thread.Sleep(1000);
Console.WriteLine("Process:{0} CPU% {1}", proc.ProcessName, pcProcess.NextValue());
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question