static void Main(string[] args) { PerformanceCounter pc = new PerformanceCounter("Processor", "% Processor Time", "_Total"); Console.WriteLine(pc.CounterType); Console.WriteLine(pc.CounterName); Console.WriteLine(pc.CounterHelp); while(true) { Thread.Sleep(TimeSpan.FromSeconds(1)); float cpuInfo = pc.NextValue(); Console.WriteLine("cpu当前使用率为{0}",cpuInfo); } Console.ReadLine(); }
更好的文章等着我们去学习http://wsql.iteye.com/blog/1515823