Reading carefully you'll see they explain this:
"... The TickCount property handles an overflow condition by resetting its
value ..."
Well regarding the faith in the system.... I don't see much difference.
System working for only 50 days is as bad as system working for 25. :) I
rather think that they use Int32 because usnigned types are not CLS
compliant.
Anyways, as I said 50 is not much better than 25, so I believe if you look
for bigger accuracy you'll be better off with reading *System Up Time*
performance counter.
using System.Diagnostics;
.....
PerformanceCounter upTime = new PerformanceCounter("System","System Up
Time");
// You've got to call this twice. First time it returns 0 and
// second time it returns the real info.
upTime.NextValue();
MessageBox.Show(String.Format(TimeSpan.FromSeconds (upTime.NextValue()).ToString()));
You need to keep in mind the following:
1. Performance counters are part of WMI and as such they are protected by
their own security settings (user rights are privileges). It won't be a
problem for desktop applications, but it might be for web application when
using impersonation.
2. Reading performance counters is not one of the fastest operations and
you might run into performance problems if you do this very often
3. "Syste Up Time" takes into consideration only the time when the system is
running that is the time that the system spend in hibernation does no count.
Thus this counter cannot be used to calculate the exact system boot date and
time.
--
Stoitcho Goutsev (100) [C# MVP]
to zero. The minimum value returned by TickCount is 0.
"Danny Tuppeny" <gr****@dantup.me.uk.remove> wrote in message
news:43***********************@ptn-nntp-reader03.plus.net...
Stoitcho Goutsev (100) [C# MVP] wrote: System.Environment.TickCount has nothing to do with DateTime and its
100-nanoseconds accuracy. They are implemented differently and they
expilicitly state this in MSDN:
MSDN:
" Remarks
The value of this property is derived from the system timer and is stored
as a 32-bit signed integer. Therefore, the elapsed time will wrap around
to zero if the system is run continuously for 24.9 days.
Wrap around to 0? I thought a signed in would go to negatives when it
overflowed?
eg. 24.8 -> 24.9 -> -24.9 -> -24.8 ??
(I've never written anything that relies on this "fact", it was just my
understanding!)