LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling QuitUserInterface() from within a thread function

Hello,
 
I have a dialogue which is created as a child process and communicates with the parent using pipes. Within the dialogue application, I have a listener thread function which checks for incoming pipe messages and reacts accordingly. One such message is 'terminate', and in response to this I'd like to be able to call 'QuitUserInterface()' to terminate the application. Presumably this function requires visibility of the dialogue application that it is terminating and does not have this within the thread function, and therefore does not work. Is there a way to get round this?
 
Thanks in advance.
 
Marc.
0 Kudos
Message 1 of 6
(3,930 Views)

Correct me for thinking too simply, but why not just pipe a message back to the parent to do the termination?

Ian.

0 Kudos
Message 2 of 6
(3,928 Views)
Ian,
 
Thanks for your quick response. I think it is better for the dialogue to terminate itself given that there are named server pipes that need to be cleaned up and that the dialogue may not die gracefully if it is in the process of doing something.
 
Regards,
 
Marc.
0 Kudos
Message 3 of 6
(3,924 Views)
Get the dialog to clean itself up, close any pipe servers, etc., then pipe the message to the parent to terminate both of them.
0 Kudos
Message 4 of 6
(3,922 Views)

Yes, that is a good solution, thanks. I am still curious though if it is possible to pass a dialogue handle to a thread function and use it to manipulate the dialogue - like you can in VC++.

Regards,

Marc.

0 Kudos
Message 5 of 6
(3,920 Views)

I've found another solution. QuitUserInterface() cannot be called from inside a child thread, therefore I created a new CVI callback function DeferredQuit(), which calls QuitUserInterface() instead. I then use PostDeferredCall() to call DeferredQuit() from inside my thread. This ensures that the QuitUserInterface() gets executed as part of the main thread.

0 Kudos
Message 6 of 6
(3,911 Views)