Tuesday, March 22, 2005

Windows 25 Day Limit (Environment.TickCount)

I found This (Environment.TickCount) system property while looking for a way to get my System Up Timer to run in the system tray. It runs in the system tray now, and TickCount allows me to ask the system how long in milliseconds the system has been running for, so when you load the program it displays how long the system has been running for instead of how long the app has been running for.

Something I noticed is that Environment.TickCount returns an Integer variable, and the biggest number an Integer can hold is 2,147,483,647. So TickCount can only track the time the system has been running for as long as the system hasn't been running for longer than *Goes and uses Excel* 24 Days, 20 Hours, 31 Minuets, 23 Seconds and 647 Milliseconds.

My program will track the system time for about 97 years because it uses multiple variables (all smaller than an Integer), but since the TickCount property only tracking time for 25 days it makes me wonder what happens when that time elapses. Most likely TickCount would just goes back to zero, otherwise there would be a buffer overflow and the system would swear at the user, but is Microsoft really so pessimistic on how long a system will run for!?