Click here to Skip to main content
15,889,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a performance counter like this:

http://i.imgur.com/lm43Kgk.png

And I have this code in Timer1:
VB
Label1.Text = "CPU Usage: " & CInt(PerformanceCounter1.NextValue).ToString 


This is my problem (on the left is Label1 with 41% CPU usage and on the right is the Task Manager with 6% CPU usage respectively):

http://i.imgur.com/UOP4KJo.png

What am I doing wrong?
Posted
Updated 18-May-14 0:48am
v3
Comments
Duncan Edwards Jones 18-May-14 12:13pm    
Is your display on the performance monitor application set to "Current" or "Average" and does the CounterType of your code performance counter match that?
Member 10597507 18-May-14 17:04pm    
It's set to average, I believe. Though my problem is that when I use CounterName Processor And InstanceName _Total the results are accurate (both the Performance Monitor & Performance Counter) but when I try to use CounterName Process and InstanceName a specific process, it's always wrong and goes high especially when I move the mouse over the application.
Duncan Edwards Jones 19-May-14 10:43am    
Is the CPU being read from _within_ that process?
If so, maybe it can only be read when that process has (some of the) the CPU and so it will therefore not reflect the true reading...?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900