Question CPU Usage in %

sonia.sardana

Active member
Joined
Jan 25, 2009
Messages
35
Programming Experience
Beginner
Can i know hoe to find the CPU Usage of individual Process in %.
I found the following code thru the net-
But I not getting it.

VB.NET:
Private m_PerformanceCounter As New System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", "_Total")
Dim cupcount As String = CInt(m_PerformanceCounter.NextValue()) & "%"


Here m_PerformanceCounter.NextValue() will gives the cpu usage percentage

What we have to write in place of these
1) Processor
2)% Processor Time
3)_Total

Any help will be greatly Appreciated.
 
Last edited by a moderator:
FYI means For Your Information; not relevant in your thread title.

You should be able to get the categoryNames like this:

VB.NET:
		For Each category As PerformanceCounterCategory In PerformanceCounterCategory.GetCategories()
			MessageBox.Show(category.CategoryName)
		Next

I would rather run perfmon and look up the categoryName, counterName, & instanceName of what I'm interested in monitoring. As you can see the category I've chosen is "Processor" the counter name is "% Processor Time" and the instance is "_Total".
 

Attachments

  • Perfmon.jpg
    Perfmon.jpg
    18.1 KB · Views: 28
Back
Top