PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");
string cpuUsageStr = string.Format("{0:f2} %", cpuCounter.NextValue());
string ramAvaiableStr = string.Format("{0} MB", ramCounter.NextValue());
lable1.Content = $"CPU:{cpuUsageStr} RAM:{ramAvaiableStr}";
- 本文标题: C# 获取CPU和内存占用情况
- 文章分类:【WinForm/WPF】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.