Asynchronous Timer Fires at Irregular Intervals When Interval > 600 SecondsPrimary Software: LabWindows/CVI Development Systems>>Full Development SystemPrimary Software Version: 7.1 Primary Software Fixed Version: N/A Secondary Software: LabWindows/CVI Development Systems>>Base Package
Problem: When the interval of the asynchronous timer is set to 600 seconds or above, the timer is fired at unpredictable intervals. In particular, when the interval is set to 600 seconds, the asynchronous timer callback is called at 171 seconds. What is the source of this problem, and how do I resolve it? Solution: The CVI asynchronous timers rely on the Windows multimedia timers (see ..\CVI\toolslib\toolbox\asynctmr.c for details) to fire the event at the appropriate time. The incorrect behavior you are seeing is caused by an issue with the windows timers where they wrap around every 429496 milliseconds. For any interval, x larger than 429496 milliseconds, a wrap occurs and the timing interval is actually x-429496 milliseconds. This issue has been reported to Microsoft. More information on the behavior of the multimedia timer and the bug report can be found in the linked MSDN discussion. As a workaround, you can change the interval of the timer to 1 second (i.e. use single shot events), manually track the number of elapsed timer ticks and perform an operation after the desired time elapses. For instance, instead of setting the timer interval to 600 seconds, set the timer interval to 1 second and increment a counter in the timer callback each time it is called. On the 600th call to the timer callback, perform the code you would like executed every 600 seconds. Note: The behavior in this KnowledgeBase only occurs when the time interval is larger that the wrap around interval of the Windows multimedia timer. Therefore, if you keep the asynchronous timer interval below the wrap around time specified above, you can avoid this behavior. Related Links: MSDN: Multimedia Interval Discussion Attachments:
Report Date: 06/20/2005 Last Updated: 06/20/2005 Document ID: 3LPL8QD1 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
