I'm trying to get the cpu usage, but I allways get a 0%. Also I tried to get avaliable ram, and it works, but not the cpu usage.
code:
PerformanceCounter cpuCounter;
PerformanceCounter ramCounter;
cpuCounter = new PerformanceCounter();
cpuCounter.CategoryName = "Processor";
cpuCounter.CounterName = "% Processor Time";
cpuCounter.InstanceName = "_Total";
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
MessageBox.Show(cpuCounter.NextValue() + "%");
MessageBox.Show(ramCounter.NextValue() + "Mb");
What's wrong? or it's another way to get it?
Thanks