int NewAsyncTimer (double interval, int count, int initialState, void *eventFunction, void *callbackData);
Creates a new asynchronous timer and returns a timer ID you can use to identify the timer in subsequent function calls.
NewAsyncTimer creates asynchronous timers that run in threads with priority THREAD_PRIORITY_HIGHEST.
RT To specify a different priority, call NewAsyncTimerWithPriority.
![]() |
Note You can use asynchronous timers on Windows, real-time (RT), and Linux operating systems. |
| Input | ||||
| Name | Type | Description | ||
|---|---|---|---|---|
| interval | double | Specifies the wait interval between timer events (in seconds). Depending on the model of the machine you are working on, the minimum interval value that you can use may differ. An interval less than the resolution of the asynchronous timer results in timer events with an interval equal to the asynchronous timer resolution. Call GetAsyncTimerResolution to get the asynchronous timer resolution for your system. |
||
| count | integer | Specifies the number of timer events to be generated before the timer is automatically discarded. If you pass a negative value, the timer will generate events until it is discarded by a call to DiscardAsyncTimer or suspended by a call to SuspendAsyncTimerCallbacks.
|
||
| initialState | integer | Specifies whether the timer should be running (generating timer events) or suspended once it is created. You can change the state of an individual timer by calling SetAsyncTimerAttribute. You can change the state of all timers as a whole by calling ResumeAsyncTimerCallbacks or SuspendAsyncTimerCallbacks. |
||
| eventFunction | void * | Specifies the name of the user function that processes the callback. This event function (type AsyncTimerCallbackPtr) takes the same form as the timer control callback function: int CVICALLBACK FunctionName (int reserved, int timerId, int event, void *callbackData, int eventData1, int eventData2); The first parameter of the event function is reserved. timerId is the timer that caused the callback. The types of events generated are EVENT_TIMER_TICK and EVENT_DISCARD. eventData1 is a pointer to a double that represents the current time in seconds and is relative to the start of the first timer event. eventData2 is a pointer to a double that represents the time that has elapsed since the last call to the timer callback. The elapsed time is set to zero if the callback has not been called previously. The resolution of eventData1 and eventData2 matches the resolution of the asynchronous timer. Callback data defined by the user also is passed to the event function. |
||
| callbackData | void * | Specifies a pointer to user-defined data passed to the event function. | ||
| Name | Type | Description | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| timerID | integer | Specifies the ID that is used to reference the timer in subsequent
function calls. Negative values indicate that an error occurred.
|