SpinWait.SpinUntil incorrectly uses unstable system time. - by Cory Nelson

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 621869 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/14/2010 8:01:26 PM
Access Restriction Public


System.Threading.SpinWait.SpinUntil(Func<bool>, int) is supposed to stop spinning after it has tried for a number of milliseconds.

The current implementation, however, is based on the system time -- instead of trying for 'n' milliseconds, it tries until the system time reaches now+'n'.  The difference is subtle, but means it can incorrectly try for too long or for too short if the system time changes.

The implementation should be changed to use either Environment.TickCount or a Stopwatch, which are not affected by the system time and will ensure it always tries for the correct amount of milliseconds.
Sign in to post a comment.
Posted by Microsoft on 11/15/2010 at 1:13 AM
Thanks for your feedback.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/14/2010 at 8:22 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)