LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Small change in the WriterGUI sample code coming with CVI 2013

I propose to modify the QuitCallback as follow.

In the version hereafter there is a test on the thID before the CmtWaitForThreadPoolFunctionCompletion call

This may be necessary because if for any reason you run the WriteGUI sample code but, for any reason, do not use the Start button then Quit you get an error because thId is not yet a valid thread handle.

Regards, Philippe

 

/*----------------------------------------------------------------------------*/
/* QuitCallback                                                               */
/*----------------------------------------------------------------------------*/
int CVICALLBACK QuitCallback (int panel, int control, int event,
                void *callbackData, int eventData1, int eventData2) {
  switch (event) {
    case EVENT_COMMIT:
    {
      stop = 1;
      if(thID){
        CmtWaitForThreadPoolFunctionCompletion(DEFAULT_THREAD_POOL_HANDLE, thID, OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
        CmtReleaseThreadPoolFunctionID(DEFAULT_THREAD_POOL_HANDLE, thID);
      }
      QuitUserInterface (0);
      break;
    }
  }
  return 0;
}

 

0 Kudos
Message 1 of 1
(3,409 Views)