In my application I have a timer that runs 4 times per second checking the hardware connected. When some start condition is matched, a test function must be executed that runs for several seconds. During this time no other functions must be launched.
When using a conventional timer, I setup my application as follows:
Timer callback:
// Check for serial hardware connected
// In case the starting condition is encountered:
// PostDeferredCall the testing routine
// else
// display some diagnostic value
// End of timer function
Testing routine:
// Disable timer execution
SetCtrlAttribute (panel, control, ATTR_ENABLED, 0);
// Run the tests
// ...
// At the very end, enable timer again
This structure work
s well: only one testing routine is launched at a time.
When transferring my application to asyncronous timers, I found that more than one testing routine are launched. Seems that when a timer event is executing, there are some more events (3 or 4) queued in the system, so that even if the first instruction in the testing routine is disabling the timer, some more timer events are still executed.
Disabling the timer inside the timer callback istself has not solved the problem (and I don't even know if this is correct or not).
I had to use a global flag set in the testing routine that causes the timer callback to end immediately after called.
What can be happening? Is my hipothesis correct or am I missing some basic concept regarding asyncronous timers?
CVI 6.0.0 on a Celeron machine with WINXP Pro. No other applications running.
Thanks
Roberto