Getting CPU utilization of a specific service in C #

I want to know the CPU usage of a specific service in C #.

PerformanceCounter works great with the 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(); 
+7
c # windows service
source share
1 answer

The correct performance counter name will be

 PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "ACService", true); 
+4
source share

All Articles