Getting CPU usage of a specific Service in C#

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();

性能计数器的正确名称是

PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "ACService", true);
链接地址: http://www.djcxy.com/p/87864.html

上一篇: 添加关系到Laravel工厂模型

下一篇: 在C#中使用特定服务的CPU使用情况