R
Rob Meade
Hi all,
I'm having a bit of trouble with the following function....
Private Function GetSystemUpTime() As TimeSpan
' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter
' create new instances of our objects
PerformanceCounter = New PerformanceCounter("System", "System Up Time")
' populate
Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue())
' return result
Return Result
End Function
For some reason I keep getting the value 0 (zero) for days, hours,minutes,
seconds etc - ie, I've tried this on 2 machines now and the result is always
the same. I've tried other counters using a similar method (for available
memory,application restarts etc) and they do come through...
Can anyone shed any light on this for me...
PS: I've had a bit of a look online and I'm aware of the environment.tick
thing but that has a problem over a value of 24 (goes to minus numbers) so
would prefer to use a PerformanceCounter object.
Regards
Rob
I'm having a bit of trouble with the following function....
Private Function GetSystemUpTime() As TimeSpan
' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter
' create new instances of our objects
PerformanceCounter = New PerformanceCounter("System", "System Up Time")
' populate
Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue())
' return result
Return Result
End Function
For some reason I keep getting the value 0 (zero) for days, hours,minutes,
seconds etc - ie, I've tried this on 2 machines now and the result is always
the same. I've tried other counters using a similar method (for available
memory,application restarts etc) and they do come through...
Can anyone shed any light on this for me...
PS: I've had a bit of a look online and I'm aware of the environment.tick
thing but that has a problem over a value of 24 (goes to minus numbers) so
would prefer to use a PerformanceCounter object.
Regards
Rob