LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

exit hangs when calling c++ dll

I'm calling a dll function written in borland c++. The function executes fine and returns to my labwindows application. When I try to exit labwindows with QuitUserInterface(0), the following happens:

1. I'm returned to the cvi ide screen, but the 'stop' button (stopsign) does not work
2. My gui panel is still up, but nothing is active on it. No keypresses are processed
2. If I go to the <<running>> symbol at the upper left, I can select 'terminate execution' and that works. 'break' does not work.

My dll function messes with the serial port, for what that's worth.

In running the dll in debug mode, I've determined that the main threadID associated with the cvi application is never terminating, even though my 'return 0;' at the end of the main cvi function does get executed.

Any ideas?

- John

int main (int argc, char *argv[])
{
    int mainId;
    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;  /* out of memory */
    if ((panelHandle = LoadPanel (0, "main.uir", PANEL)) < 0)
        return -1;
    DisplayPanel (panelHandle);
    RunUserInterface ();
    DiscardPanel (panelHandle);
    return 0;                                        // <-- this definitely DOES get executed, but process doesn't quit as it should.
}

int CVICALLBACK exitApp (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    int errNum;
    switch (event)
        {
        case EVENT_COMMIT:
              errNum = QuitUserInterface(0);
              DebugPrintf("UserIntQuit error: %d\n",errNum);
            break;
        }
    return 0;
}



0 Kudos
Message 1 of 2
(3,576 Views)
I am such a happy camper, I figure out what was going on.

The DLL function, after opening the com port, was not closing it. For some reason this kept the CVI application from exiting gracefully, which I find odd.

Added a com port close and it works flawlessly.

Woo - hoooo !!!!

- John
0 Kudos
Message 2 of 2
(3,570 Views)