我想知道C#中特定服务的CPU使用率。

PerformanceCounter可以很好地处理流程:

PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "myprocess", true);
double result = counter.NextValue();

但不提供服务:
   PerformanceCounter counter = new PerformanceCounter("Service", "% Processor Time", "myservice", true);
    double result = counter.NextValue();

最佳答案

性能计数器的正确名称是

PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "ACService", true);

07-24 09:22