using System; using System.Diagnostics; using System.Threading; namespace CpuUsageTest { internal class Program { static PerformanceCounter counter = new PerformanceCounter("Processor Information", "% Processor Utility", "_Total"); static void Main(string[] args) { counter.NextValue(); while (true) { Thread.Sleep(500); Console.WriteLine(counter.NextValue()); } } } }
积跬步,至千里!