By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

How to detect total CPU percentage utilization

P: n/a
dgk
For the whole machine, not a specific process. I looked at an earlier
thread by Cor and Ken Tucker, but I don't find anything in the
management that looks like... Oh. Here is a really good site. Really,
I don't know the guy but just found it via Google. I guess I don't
need to post this anymore but just in case someone else is looking for
the info, here it is. It's in C# but nobody is perfect.

http://skilldrive.com/book/DOTNETinS...#_Toc112335378

Set a reference to System.Management and adapting the earlier thread's
code:
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")
moReturn = moSearch.Get
For Each mo In moReturn
Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("LoadPercentage"))
Debug.WriteLine(strout)
Next

LoadPercentage is the key for what I was looking for. Two comments
about the code. First, why would there be more than one mo returned? I
guess multi-processor systems. I'll have to try it on my dual-core at
home.

Second, the "Select * from Win32_Processor" parameter. Kind of cute,
looks like a foreshadowing of DLINQ. Using SQL syntax for non-database
objects I think. Nice.

I started out by trying MY, as in My.Computer.Info but no CPU stuff is
there. Too bad, I'm getting spoiled by My.
Nov 14 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Could you not detect the System Idl Process ? 100 - Idle = used

Just a thought.

Miro
"dgk" <dg*@somewhere.comwrote in message
news:ib********************************@4ax.com...
For the whole machine, not a specific process. I looked at an earlier
thread by Cor and Ken Tucker, but I don't find anything in the
management that looks like... Oh. Here is a really good site. Really,
I don't know the guy but just found it via Google. I guess I don't
need to post this anymore but just in case someone else is looking for
the info, here it is. It's in C# but nobody is perfect.

http://skilldrive.com/book/DOTNETinS...#_Toc112335378

Set a reference to System.Management and adapting the earlier thread's
code:
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")
moReturn = moSearch.Get
For Each mo In moReturn
Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("LoadPercentage"))
Debug.WriteLine(strout)
Next

LoadPercentage is the key for what I was looking for. Two comments
about the code. First, why would there be more than one mo returned? I
guess multi-processor systems. I'll have to try it on my dual-core at
home.

Second, the "Select * from Win32_Processor" parameter. Kind of cute,
looks like a foreshadowing of DLINQ. Using SQL syntax for non-database
objects I think. Nice.

I started out by trying MY, as in My.Computer.Info but no CPU stuff is
there. Too bad, I'm getting spoiled by My.

Nov 14 '06 #2

P: n/a
dgk
On Tue, 14 Nov 2006 14:10:48 -0500, "Miro" <mi******@golden.net>
wrote:
>Could you not detect the System Idl Process ? 100 - Idle = used

Just a thought.

Miro
Good thinking. Is that a real process?
Nov 15 '06 #3

P: n/a
Take a look at this link.

This might help you
Ive only delt with processes, not the system Idle processes, but it seems he
is doing the same thing ur trying to do.

http://www.codeproject.com/csharp/processescpuusage.asp
M.
"dgk" <dg*@somewhere.comwrote in message
news:tc********************************@4ax.com...
On Tue, 14 Nov 2006 14:10:48 -0500, "Miro" <mi******@golden.net>
wrote:
>>Could you not detect the System Idl Process ? 100 - Idle = used

Just a thought.

Miro

Good thinking. Is that a real process?

Nov 15 '06 #4

P: n/a
dgk
On Wed, 15 Nov 2006 11:03:06 -0500, "Miro" <mi******@golden.net>
wrote:
>Take a look at this link.

This might help you
Ive only delt with processes, not the system Idle processes, but it seems he
is doing the same thing ur trying to do.

http://www.codeproject.com/csharp/processescpuusage.asp
Thanks.
Nov 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.