I want to know the CPU usage of a specific service in C#.
PerformanceCounter works fine with process:
PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "myprocess", true);
double result = counter.NextValue();
but not with services:
PerformanceCounter counter = new PerformanceCounter("Service", "% Processor Time", "myservice", true);
double result = counter.NextValue();
The correct name for the performance counter would be
PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "ACService", true);