473,507 Members | 12,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect total CPU percentage utilization

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
4 2630
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2633
by: Tom Siltwater | last post by:
building variable width/DB tables etc using getrows instead of movenext. Performance is a major concern as this app requires SSL. My question is, when does it become more about the challenge of...
5
4354
by: James Conrad StJohn Foreman | last post by:
Have found http://www-128.ibm.com/developerworks/db2/library/techarticle/lyle/0110lyle.html which is quite helpful, but doesn't quite tell me what I want. I have a table, advertising_spend with...
0
1673
by: ipramod | last post by:
Hi, I just wanted to calculate CPU Percentage Utilization in ASP.Net application using a thread. I have written following code: protected void Page_Load(object sender, EventArgs e) {...
7
13913
by: balach | last post by:
hi all, i am new in .NET, some body please help me regarding calculating total cpu utilization and RAM memory utilization in percentage (Accurately) on page load event of ASP.NET. i found the...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.