Hi AL.
You are correct. The following calls do not change the callback schedule, they merely prevent the callbacks occurring:
SuspendAsyncTimerCallbacks ();
SetAsyncTimerAttribute (TimerHandle, ASYNC_ATTR_ENABLED, 0);
You wrote:
"i have thought of discarding the timer after 10 seconds and create a new one again if user continues ..."
This is in fact the way to go.
When you create an asynchronous timer, you specify how / when it is to be discarded.
In this case, let's allow it to generate just _one_ callback.
Try this:
/*****************************************************/
void CVICALLBACK Execute (int menuBar, int menuItem, void *callbackData, int panel)
{
TimerUp = 0;
// Note: second parameter (Count) changed from -1 to 1
// So, the timer will be automatically discarded after 1 callback
TimerHandle = NewAsyncTimer (10.0, 1, 1, ExecutionTimer, NULL);
Execution (); // Go to function
// Realise that this discards ALL async timers; maybe this belongs in main()?
//DiscardAsyncTimer (-1);
}
int CVICALLBACK ExecutionTimer (int reserved, int theTimerId, int event, void *callbackData,
int eventData1, int eventData2)
{
if (event == EVENT_TIMER_TICK)
{
// Don't need this line, as timer will be automatically discarded
//SetAsyncTimerAttribute (TimerHandle, ASYNC_ATTR_ENABLED, 0); // disable timer
TimerUp = 1;
}
return 0;
}
void Execution (void)
{
while (some other parameters)
{
if (TimerUp == 0)
do some stuff
else
{
popup ... continue?
if (yes)
{
TimerUp = 0;
// Don't need this line, as the timer no longer exists!
//SetAsyncTimerAttribute (TimerHandle, ASYNC_ATTR_ENABLED, 1); // enable timer
// Create a new timer and continue
// This guarantees the corrrect timing for your callback
TimerHandle = NewAsyncTimer (10.0, 1, 1, ExecutionTimer, NULL);
}
else
return;
}
}
}
/*****************************************************/
By the way, you can get the help you wanted by right-clicking (on a control or the body of the function panel), by pressing [F1] or [Shift-F1], or via the Help menu.
Good luck.
Colin.