Processor usage

jvcoach23

Centurion
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
a while back I ran accross a sample app that showed the processor usage... kind of like taskman does.. but it was in the lower left hand corner of the screen and was transparent like.. it was always on top no matter what else was running. anyway.. it was kind of cool and I've learned enough I'd like to look at the code but can't find the example anymore. does anyone know what I'm talking about and if so.. can you point me to the code.

thanks
shannon
 
Ok, this is not the example you are talking about, still, it does show the CPU usage...

Code:
using System.Diagnostics.PerformanceCounter class.

//add this on the declarion zone
protected PerformanceCounter cpuCounter;

//you can add this at the form's LOAD event
cpuCounter = new PerformanceCounter();
cpuCounter.CategoryName = "Processor";
cpuCounter.CounterName = "% Processor Time";
cpuCounter.InstanceName = "_Total";

/*
Call this method every time you need to know
the current cpu usage.
*/
public string getCurrentCpuUsage()
{
    cpuCounter.NextValue()+"%";
}

I hope it helps...
 
Back
Top