PerformanceCounter pfCPUTime = new PerformanceCounter("Process", "% Processor Time", process.ProcessName); pfCPUTime.NextValue(); CPUUseRate = Math.Round(pfCPUTime.NextValue() / Environment.ProcessorCount, 2);
是通过计数器获取的。问题是运行的时候获取的值是20%以上,为什么调试的时候就获取正确的值了大概是在0~2%….