// JP opened flex table

Click to See Complete Forum and Search --> : timer queues


robertcc
January 22nd, 2008, 11:48 AM
I have a C++ program which needs to execute some code on a regular, timed, basis. A timer interval of 20 ms would be typical.



I have been reading about timer queue functions and it seems like this is what I should use. However, from what I have read so far, it sounds like the callback function would be called every 20 ms even if the previous call to the callback function was not finished.



Is there any way to prevent this? I only want the callback function called if the previous call to this function has finished. If it hasn't, the timer event should be ignored until the next time around.

MrViggy
January 22nd, 2008, 12:32 PM
Well, one way is to disable the timer in the callback. Another is to set a flag at the start of your callback function, and clear it at the end of the function. If the flag is set when you enter the function, just return.

Viggy

VladimirF
January 22nd, 2008, 01:35 PM
I only want the callback function called if the previous call to this function has finished. If it hasn't, the timer event should be ignored until the next time around.You have to decide WHEN do you want your function to be called next time (if it was busy at the 20ms tick):
- as soon as possible (after the function returns)?
- as close to 20ms tick marks as possible (regardless of the missed ones; MrViggy's suggestion provides that)?
- in 20 ms after the function returns?

//JP added flex table