【发布时间】:2019-12-24 07:17:04
【问题描述】:
我最近从 c# 迁移到 .net 核心。在 c# 中,我用这个来获取 CPU 使用率:
PerformanceCounter cpuCounter;
PerformanceCounter ramCounter;
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
public string getCurrentCpuUsage(){
return cpuCounter.NextValue()+"%";
}
但是.net core PerformanceCounter 不可用,解决方案是什么?请给我一个建议。
【问题讨论】: