Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

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

 

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...