did you see and use the code exactly Remember, there may not be CPU activity causing it to remain at 0. you also need to place it on a timer and keep it running every second for example to see the status.
drag a label on the form
drag a button on the form
drag a timer on the form.
set the timer interval to 1000. Enable it also
go into code view
scroll up to enter global decleration (after public class....):
PerformanceCounter theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
double click button. Type:
if (this.theCPUCounter == null)
{
this.theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
How to obtain current CPU Loading
kewpcg
PerformanceCounter theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
Console.WriteLine(theCPUCounter.NextValue().ToString());
Alexander_Monday
you can use the performance counters to do this...
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=773531&SiteID=1
danni123
did you see and use the code exactly Remember, there may not be CPU activity causing it to remain at 0. you also need to place it on a timer and keep it running every second for example to see the status.
drag a label on the form
drag a button on the form
drag a timer on the form.
set the timer interval to 1000. Enable it also
go into code view
scroll up to enter global decleration (after public class....):
PerformanceCounter theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
double click button. Type:
if (this.theCPUCounter == null)
{
this.theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
}
this.timer1.Start();
go back to form view
double click timer to make a tick event
then type in here:
this.Label1.Text = this.theCPUCounter.NextValue().ToString();
run the application and press the button to start the timer/process
Patrick Tremblay
All right,all is OK.
Thanks in advance!!
GeniusManiac
another question:
why this.theCPUCounter.NextValue() is alway zero
thanks
Jason Callas