I am looking for a way to get the process name that the highest processor consumes. Here is my code that uses the process of using the processor
static void Main(string[] args)
{
PerformanceCounter myAppCpu =
new PerformanceCounter("Process", "% Processor Time", "OUTLOOK", true);
float firstValue = cpuCounter.NextValue();
System.Threading.Thread.Sleep(1000);
int secondValue = (int)cpuCounter.NextValue();
}
For the whole system CPU I have
PerformanceCounter cpuCounter = new PerformanceCounter();
cpuCounter.CategoryName = "Processor";
cpuCounter.CounterName = "% Processor Time";
cpuCounter.InstanceName = "_Total";
float firstValue = cpuCounter.NextValue();
System.Threading.Thread.Sleep(1000);
int secondValue = (int)cpuCounter.NextValue();
Is there any way that I can find the most processor process?
source
share