public class MyClass {
PerformanceCounter counter = null;
public float CpuUsage {
get {
if (counter == null) {
counter = new PerformanceCounter ("Processor", "% Processor Time", "_Total");
}
return (counter.NextValue ());
}
}
}