What happens if I set the interval on a System.Timers.Timer to .5 ?
This is some more text that I’m adding so the stupid filter will let me post this question.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Typically, nothing. In general, the timers within Windows are only accurate to a specific interval, somewhere around 15ms. Anything smaller than that will normally just cause the timer to fire once every 14-15ms or so.
That being said, the framework isn’t Windows-only. On a different real time operating system, you could potentially get the timer to raise events more frequently than once every millisecond. The framework API doesn’t assume that you’ll be dealing with the limitations of non-real time operating systems, even though practically this is the case (most of the time).
Note that, internally,
System.Timers.Timeractually uses aSystem.Threading.Timerfor its implementation, which uses an Int32 for period and dueTime. As such, it is impossible for the Windows version to have non-integer timings. The framework usesMath.Ceilingon the Interval passed, so you would get a 1ms interval. That being said, this is an implementation detail, so not something that would or should be relied upon in general.