Asynchronous Timers Control
toolslib\toolbox\asynctmr.fp
This instrument driver provides timer callbacks that execute in their own threads. Because they execute in their own threads, the timer callbacks are called even when the main thread of your program is not processing events.
These timer callbacks are ideal for tasks, such as data acquisition, that must be executed at reliable intervals.
Timer Behavior on Different Operating Systems
You can use asynchronous timers on Windows and real-time (RT) operating systems. The timers behave similarly, though not identically, on these different systems. On Windows, asynchronous timers are implemented using the Windows multimedia timer functions. On RT systems, asynchronous timers are implemented using the LabVIEW microsecond timing engine. On both systems, LabWindows/CVI generates a timer event for every timer tick, even when the timer runs behind.
![]() |
Note You can create up to 16 asynchronous timers on Windows systems and up to 128 on RT systems. |
The minimum interval value that you can use depends on the system that is running the asynchronous timer. If the interval is smaller than the asynchronous timer resolution supported by your system, LabWindows/CVI uses an interval equal to the resolution supported by the system. On Windows, the minimum interval value is typically 10ms. On RT systems, the minimum interval value can be as small as 1 microsecond. You can call GetAsyncTimerResolution to determine the resolution for your system.
The type of system on which you run asynchronous timers also determines in what threads the timer callback functions execute. On Windows, all asynchronous callback functions share a common thread that the operating system manages. If you want your program to execute multiple functions in parallel, National Instruments recommends that you use the LabWindows/CVI Utility Library thread pool functions instead of the asynchronous timer functions. On RT systems, every timer runs in its own dedicated thread.
On all system types, any variables that the asynchronous callback references or changes are not protected from being referenced or changed by another thread, such as the main process thread. You can use the multithreading utility functions in the Utility Library to protect the variables that are accessed from more than one thread.
Timer callbacks cannot interrupt each other. One timer thread must exit its callback before another timer thread can call its callback.
On Windows, a call to create or discard an asynchronous timer will not complete until all outstanding asynchronous callbacks return. On RT systems, a call to create an asynchronous timer will complete regardless of outstanding callbacks. A call to discard an asynchronous timer blocks only on outstanding callbacks for the timer that you are discarding.
(Linux) You also can use asynchronous timers in applications you run on Linux. Asynchronous timers on Linux are implemented using the POSIX real-time timer functions. Hardware permitting, asynchronous timers on Linux systems can support an interval as small as 1 nanosecond. Asynchronous timers on Linux share a common thread that the POSIX real-time library manages. LabWindows/CVI skips timer events when the timer runs behind in Linux applications. On Linux, a call to create or discard an asynchronous timer will not complete until all outstanding asynchronous callbacks return.
![]() |
Note You can create up to 256 asynchronous timers on Linux systems. |