LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

difference between the timer control and the asynchroism timer

I am using the CVI5.5 and want to use the asynchroism timer.what is the difference between it and the timer control.In detail,please.
thanks a lot
yours truly
tracy
0 Kudos
Message 1 of 2
(3,013 Views)
Hello Tracy,
The UI Timer works like other UI objects. When an event occurs (a timer tick in this case) a message is placed at the back of the current thread's event queue. When ProcessSystemEvents() is called and the EVENT_TIMER_TICK is at the front of the event queue, then the timer callback is called. Recall that ProcessSystemEvents() is called continuously by RunUserInterface(). If your UI is not very busy, this timer can be quite reliable and responsive. If your UI is busy or your application has some slow (long) callbacks, the timer could have some jitter (due to the UI blocking the timer callback). If your timer must have increased accuracy, consider using the asynchronous timer. With the asynchronous timer, whenever the timer "fires", a separate thread
immediately runs your timer callback function. Thus events occurring on the UI will have much less interference on the processing of your timer callback. There is a good example program at \samples\toolbox\asyncdem.prj that demonstrates the differences between the UI and Asynchronous Timers. Note that very short timer intervals can be unreliable using any timer ("very short" varies by processor speed, but ~25ms or less is a good rule of thumb). This is due to the 1ms grainularity of MS OS's and the number/priority of other threads running on your system.

Jeremiah Cox
Applications Engineer
National Instruments
http://www.ni.com/ask
Message 2 of 2
(3,013 Views)