whitefox 發表於 2023-6-8 12:56:57

[C#] .NET函式取得CPU使用率

引入命名空間using System.Diagnostics;PerformanceCounter CpuCount = new PerformanceCounter("Processor", "% Processor Time", "_Total");
string CpuUsage = $"{Cpu.NextValue():#0.00}%";
MessageBox.Show(CpuUsage);使用 NextValue() 即可取得CPU使用率,回傳數值是float,6.69 代表使用率 6.69%

頁: [1]
查看完整版本: [C#] .NET函式取得CPU使用率