Cum Grano Salis

Environment.TickCount returns negative numbers - MSDN doc error

This one just bit us a today.

The documentation for TickCount on MSDN say that this value is always positiove:

<Quote>
The TickCount property handles an overflow condition by resetting its value to zero. The minimum value returned by TickCount is 0.
</Quote>

And in another place in the docs:

<Quote>
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.
</Quote>

However, in MSDN2, the docs say:

<Quote>
TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days, then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days.
</Quote>

I remembered the original docs from 1.1 and so never had any reason to doubt the potential values. Apparently, in 1.1 it could go to negative numbers as well, though I have not checked that.

This bug is a female dog to find too - it will only show after 25 days without a reboot.

Published Friday, April 07, 2006 11:05 AM by Shahar
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Chris Bennet said:

Thanks for your post. This bug just got me. (VS2003, Compact Framework 1.1).
-Chris
August 20, 2006 7:08 PM
 

Virat said:

Thanks for your post. This bug got me on my production system.

July 9, 2007 9:25 PM
 

Marq said:

But we're talking WINDOWS here, how likely is it that a windows machine will run continuously for 24.9 days? Seems like an edge case to me.

November 16, 2007 5:27 PM
 

Shahar said:

A jab at windows stability! That's fresh.

;)

November 16, 2007 5:54 PM
 

Karl said:

Thanks for this information. I was fighting with this weird bug under .NET1.1 for a couple of days until I came across your blog post. I'm very astonished that I cannot find an official bug report or statement from MS. Does anybody know where I can get an official bug report or statement from MS?

January 12, 2008 1:07 PM

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Submit

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker