Wim,
You could do something like the following. Create a thread that wraps your function and launch that thread
during your callback. On your exit program callback you can simply terminate the thread manually. I suggest reading the function panel on CmtTerminateThreadPoolThread before using this option though as there are some caveats you should know about. Also make sure at some point to explicitly release your thread even if you don't end up terminating it during the process:
/*the CVI callback that you are using to launch a
int CVICALLBACK MyCallback(int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
/*Spin off a new thread that uses the function with a long delay in it*/
CmtScheduleThreadPoolFunction (tPool, Thread, NULL, &tID);
break;
}
return 0;
}
/*A thread containing your function that has a long delay*/
extern int CVICALLBACK Thread (void *Data)
{
/*Run your workhorse function here*/
}
/*The CVI callback for your exit button*/
int CVICALLBACK do_exit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
/*Terminate the long delay thread before exiting the program*/
CmtTerminateThreadPoolThread (tPool, tID, 0);
QuitUserInterface (0);
break;
}
}