C# 通过PerformanceCounter监控获取系统的cpu占用率
编程开发
PerformanceCounterCPU使用率
使用C# 监控系统的cpu占用率
首先实例化 PerformanceCounter 如下
- C# 获取整体CPU使用率
public static System.Diagnostics.PerformanceCounter CpuPerformanceCounter
= new System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", "_Total");
- C# 获取指定某个进程的CPU使用率
public static System.Diagnostics.PerformanceCounter CpuPerformanceCounter =
new PerformanceCounter("Process", "% Processor Time", "进程名称", true);
调用获取cpu使用率