【发布时间】:2011-01-15 00:34:53
【问题描述】:
我试图弄清楚如何收集我计算机上每个处理器的当前使用百分比。如果我使用“System.Environment.ProcessorCount;”我可以获取计算机上的处理器数量,它当前返回“2”。我要么不知道我在寻找什么,要么互联网上没有太多关于此的信息。
以下是我当前用于获取所有处理器组合的当前总使用百分比的代码。
protected PerformanceCounter cpuCounter = new PerformanceCounter("processor", "% Processor Time", "_Total");
public string getCurrentCpuUsage()
{
return cpuCounter.NextValue() + "%";
}
感谢您的帮助,
亚伦
【问题讨论】:
标签: c# performancecounter processor