我想在我的项目中拥有当前的 CPU 利用率
namespace Monitoring_Tool
{
public partial class ajaxExecute : System.Web.UI.Page
{
private PerformanceCounter theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
private PerformanceCounter theMemCounter = new PerformanceCounter("Memory", "Available MBytes");
protected void Page_Load(object sender, EventArgs e)
{
float cpuUsage = 0.00F;
cpuUsage = this.theCPUCounter.NextValue();
}
}
}
当我调试我的项目时, in 的值cpuUsage
正在显示0.00
,但是当我这样做QuickWatch
时,this.theCPUCounter.NextValue();
它正在显示20.6786852
.
为什么我不能将它存储在变量中?