我想知道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);