我想知道 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);
关于c# - 在 C# 中获取特定服务的 CPU 使用率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32541780/