多处理器和PerformanceCounter C#

我正在试图弄清楚如何收集计算机上每个处理器的当前使用百分比。 如果我使用“System.Environment.ProcessorCount;” 我可以获得计算机上的处理器数量,它当前返回“2”。 我要么不知道我在找什么,要么在网上没有太多关于此的信息。

以下是我目前用于获取所有处理器总当前使用百分比的代码。

protected PerformanceCounter cpuCounter = new PerformanceCounter("processor", "% Processor Time", "_Total"); public string getCurrentCpuUsage() { return cpuCounter.NextValue() + "%"; } 

感谢您的任何帮助,

亚伦

对于第一个处理器,请使用

 protected PerformanceCounter cpuCounter = new PerformanceCounter("processor", "% Processor Time", "0"); 

依此类推,最多(Environment.ProcessorCount-1).ToString()

自从我离开原来的问题后,我碰巧在Windows 7计算机上找到了Windows性能监视器( C:\Windows\system32\perfmon.msc )。 如果右键单击主窗口上的图形并选择“添加计数器”,则会显示一个可用于PerformanceCounter中作为参数的字符串列表,几乎可以显示所有要监视的内容。