c# - 在 C# 中获取特定服务的 CPU 使用率

标签 c# .net windows service

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

相关文章:

c# - C#中十进制类型的自定义舍入

c# - 这个时间值是什么格式?

c - VC:如何在.def文件中指定'unecorate'?

javascript - js-ctypes 无效参数

c# - Windows Phone 8.1 WebView 没有显示?

c# - 从 Azure Keyvault c# 获取带私钥的 X509 证书

c# - 如何将 DataGrid GroupItem 的 ContextMenu 的 MenuItem 绑定(bind)到窗口或控件的 DataContext?

c# - 如何在设计时 (C#) 隐藏一些默认控件属性?

c# - 使用 cx_freeze 进行精细编译后出现 "import clr"问题

c# - kinect中骨骼的XYZ坐标的本质是什么