By using Following Code i am trying to retrieve the CPU Usages, but its always return 0, i am also using timer in code so that the following function calling every 5 sec,
But the strange thing is that ,if i use the PerformanceCounter control then code its work perfectly ,but if i use PerformanceCounter class the its not working.
Private Function GetAllCpuUsages()
Dim cpucounter As New PerformanceCounter
cpucounter.CategoryName = "Processor"
cpucounter.CounterName = "% Processor Time"
cpucounter.InstanceLifetime = PerformanceCounterInstanceLifetime.Global
cpucounter.InstanceName = "_Total"
cpucounter.MachineName = "."
cpucounter.ReadOnly = True
TextBox1.Text = Convert.ToInt32(cpucounter.NextValue).ToString()
End Function