#include <cx/Timer.h>void *cxTimerAdd(int ms, int retrip, void (*callback)(void *), void *client)
integer function cxTimerAdd(ms, retrip, callback, client) integer ms, retrip integer client integer callback
The first parameter, ms, says how many milliseconds to delay. Once that period has elapsed, the routine callback will be called from the control wrapper; it will be given the value of clientdata as its sole parameter. Once the user callback has returned, if retrip is non-zero, the timer will be set back to the value ms and timing will continue.
Because timing is performed as a part of the event processing loop within the control wrapper, if the timer expires while the user function is executing, and the user function retains control for a long period of time, the callback will not be called on schedule.
The following is an example of how to use this routine:
/* ** This is the user-defined timer callback routine */void myCallback(void *data) { /* Do whatever needs to be done */ }
/* ** This is a code segment from the user function ** or the initialization hook function. */
void *timerHandle;
timerHandle = cxTimerAdd(250, 1, myCallback, myClientData);
In this example, the function myCallback will be called from the control wrapper every 250 milliseconds.