public int getCPUCounter() { PerformanceCounter cpuCounter = new PerformanceCounter(); cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; // will always start at 0 dynamic firstValue = cpuCounter.NextValue(); System.Threading.Thread.Sleep(1000); // now matches task manager reading dynamic secondValue = cpuCounter.NextValue(); return secondValue; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)