I have this bit of code in my quit callback:
int CVICALLBACK QuitCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
DiscardAsyncTimer (-1);
while(timer_on==1); //just to make sure!?!?
//Quit daq photodiode function
keep_reading=0;
//Turn off daq tasks
DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,binary_data_off,NULL,NULL);
DAQmxClearTask (taskHandle);
DAQmxClearTask (read_dig_taskHandle);
viClose(defaultRM);
DiscardPanel (mainHandle);
QuitUserInterface (0);
break;
}
return 0;
}
In my timer function I access the serial port and access the mainHandle etc. On rare occasions when it goes to this function to quit my program, the program is unable to quit properly. It seems the timer function still performs tasks after the discard timer is called. I can verify this by putting a breakpoint at the ViClose or DiscardPanel lines and then seeing the step through code go to my timer function and perform the code with errors (since I gotten rid of the handles necessary to perform the timer.
Note this is from the NI help file:
"Note A call to create or discard an asynchronous timer will
not complete (will block) until all outstanding asynchronous callbacks return."
Thanks in advance