[COLOR=blue]Private[/COLOR] [COLOR=blue]Shared[/COLOR] cpu [COLOR=blue]As[/COLOR] [COLOR=blue]New[/COLOR] PerformanceCounter([COLOR=maroon]"Processor"[/COLOR], [COLOR=maroon]"% Processor Time"[/COLOR], [COLOR=maroon]"_Total"[/COLOR])
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] CpuUsage() [COLOR=blue]As[/COLOR] [COLOR=blue]Single[/COLOR]
[COLOR=blue] Return[/COLOR] cpu.NextValue()
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
The first call will return 0 (that's why I made the Performance counter a shared member: make sure it does not go out of scope, or you'll instantiate a new Perf counter with every call).cBarry263 said:Thanks, I tried this, but I get 0 everytime, even when the task manager says that it is anything but 0. Did I leave something out?
cBarry263 said:Does Private Shared cpu As New PerformanceCounter("Processor", "% Processor Time", "_Total") give me the total percentage time that my paticular program has gotten? It seems like there should be something like :
Private Shared cpu As New PerformanceCounter("Processor", "% Processor Usage", "_Total") or something along those lines....
Is there anyway to find out what are the valid arguments that go in these parameters?