This example demonstrates how to call a particular function at a periodic rate. MyWorkerFunction() is called every four milliseconds. If the function returns false (zero), the loop is terminated.
int MyWorkerFunction(void);
APIRET rc;
ULONG rc2;
ULONG ulSleepDuration = 4;
int fLoop;
/* Change this thread's priority to time-critical */
rc = DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
/* Keep looping until fLoop becomes zero. */
do
{
rc2 = TimerSleep(ulSleepDuration, 0); /* Sleep */
fLoop = MyWorkerFunction(); /* Call the worker */
}
while (fLoop);