I believe in your case you want:
Dim PC As New PerformanceCounter()
PC.CategoryName = "Processor"
PC.CounterName = "% Processor Time"
PC.InstanceName = "_Total"
MessageBox.Show(PC.NextVal
Main Topics
Browse All TopicsI would like to know how can I monitor a CPU usage for a specif process using VB.net, I mean, I would like to have the same information that Task Manager provides at CPU column under Process tab.
Thank you,
Jose Roberto
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi jr_barros_jr,
I don't know if this will help you, or not. You may already have this code. The Performance Counter is similar to Frosty555. Give a shot and see. Make sure you set Timer1 Property: Enable = True and Interval = 1000. You may not get the exact % as the task manager every time, but it seems to be pretty accurate. Anyway, I hope this some help to your need.
Unfortunately, the code was essentially the same and only provided % Processor TIME. I do NOT want processor time and I want the CPU load/usage.
Example: if I run a do/loop without any code inside, this process will have 100% of CPU according to Task Manager. I want to monitor this CPU. I do not want the time.
Task Manager has both and both are different. I want the current (right now) load/usage.
Thank you,
Jose Roberto
barros,
Open up performance monitor (start->run->perfmon). Right click on the graph. Go "Add Counters". Inside you will see the various counters that exist on your system.
The "Performance Object" dropdown is equivalent to the "CategoryName" property in .NET.
The item you select from the Left Column is equivalent to the "CounterName" property in .NET.
The item you select from the Right Column is equivalent to the "InstanceName" property in .NET.
Pick whichever counter suits your needs bests.
"Processor->% Processor Time->_Total" is defined as (100 - % Processor Time for Idle Thread). It mathematically should be equal to the sum of all the % Processor Time counters for all the processes on the system.
These are the only measuers of performance that exist in a Windows system. Every other tool in windows that shows CPU usage (e.g. Task Manager) uses these counters.
Processor Time is only part of the big picture when it comes to determining how loaded the cpu is. The amount of time the CPU spends doing DPCs, context switches (time spent switching between tasks), and handling hardware interrupts are also important, and most likely Task Manager does some calculations to average this into account as well.
See this reference for what the different counters mean. It's a little more complicated than just "cpu usage".
http://technet.microsoft.c
Business Accounts
Answer for Membership
by: Frosty555Posted on 2009-04-25 at 15:22:43ID: 24233732
You want to monitor a performance counter.
You drop a performancecounter object from your toolbox on the form, and set its properties accordingly to get the CPU usage just like you would if you were using Resource Monitor. Then, in your code you repeatedly call counter.NextValue() to get the value of the counter.