Trying to find the usage of the CPU
-
Hello everybody. I'm trying to get the percentage of the CPU Usage. So far I have the following code: Dim query1 As New ManagementObjectSearcher("SELECT * From Win32_Processor") Dim moa1 As ManagementObject Dim tempa1 As Long For Each moa1 In query1.Get() tempa1 = Long.Parse(moa1("LoadPercentage").ToString()) Label3.Text = tempa1 Next When I debug with a break point and leave the mouse pointer over the label3.text I get the value of the percentange, but when i run the program without a break point the program seams for ever thinking without giving me the value. I have a timer that runs every second to update the query. What am I doing wrong? Thank you. Still trying to find the way
-
Hello everybody. I'm trying to get the percentage of the CPU Usage. So far I have the following code: Dim query1 As New ManagementObjectSearcher("SELECT * From Win32_Processor") Dim moa1 As ManagementObject Dim tempa1 As Long For Each moa1 In query1.Get() tempa1 = Long.Parse(moa1("LoadPercentage").ToString()) Label3.Text = tempa1 Next When I debug with a break point and leave the mouse pointer over the label3.text I get the value of the percentange, but when i run the program without a break point the program seams for ever thinking without giving me the value. I have a timer that runs every second to update the query. What am I doing wrong? Thank you. Still trying to find the way
-
Actually WMI IS used for accessing performance counters: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/monitoring_performance_data.asp[^]
-
Actually WMI IS used for accessing performance counters: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/monitoring_performance_data.asp[^]
I didn't say you couldn't get the perf data using WMI. I said, you SHOULDN'T use WMI for it. If you want Performance Counter data, use the PerformanceCounter classes. It's what they're there for and you don't have to wrap a bunch of WMI junk to get something that's already been wrapped for you. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome