01-28-2011 10:38 AM
Hi,
I'm running an application that has several dynamically loaded listening threads. When running in interpreted mode while developing, I noticed the threads are not closing when I stop the main VI. To try to combat this, I made an event case:
This didn't appear to help either. That is when I read in the help menu on 'close reference' the following:
"When you create a refnum to a VI, LabVIEW loads the VI into memory. The VI stays in memory until you close the refnum and until the VI meets the following conditions: There are no other open references to the referenced VI. The front panel of the VI is not open. The VI is not a subVI of another VI in memory. The VI is not a member of an open project library."
So the last part is my problem since the VI is still a member of the open library in interpreted mode. Is there any way to force closure of these threads without having to restart the project?
Solved! Go to Solution.
01-28-2011 10:41 AM
Hi kgolden,
you can close your vi if you use a property node with "FP->Open" (connect false to it) to close your vi. If you hide your vi with this property, then the window handle becomes invalid and it works.
Mike
01-28-2011 11:09 AM
Thanks Mike!
I used wired false to FP.OPEN and then closed the reference. It worked.
On an unrelated note, is there an event handler for pressing the ABORT button? That would be ideal rather than using panel close.
01-28-2011 11:13 AM
Actually no, it wouldn't. The abort is a hard close that shuts everything down immediately and won't allow you to do any cleanup. For any application I disttibute I hide the Run, and Abort buttons completely. Looking for the Application CLose, Panel Close and your own Exit/Stop is the proper way to close an application so you can do all of your necessary cleanup.
01-28-2011 11:21 AM - edited 01-28-2011 11:26 AM
Ah,
Thanks again. I actually just realized that by handling panel close? and using the "stop" vi, I effectively got the same behavior I wanted which was to be able to terminate all threads without actually closing the main VI I'm working on in the project. This will be fine for testing but in the production case, the window will have to close. I'll use the application close before deployment.
07-03-2018 11:53 PM
What do you mean by closing the VI by "Stop" vi ??
Can you further explain ? As i met the same problem that VI stored in memory even i close the main VI.
Thanks
07-04-2018 01:52 AM
That typically happens if you e.g. open a VI window with a while loop waiting for a Stop button, then Close it on 'X'. The VI is still running but now you can't access the button.
This should be handled with User events, AE or a global variable so the VI knows to stop.
/Y
07-06-2018 09:51 AM
FYI, using the stop sign is equivalent to pressing the abort button (which looks like a stop sign).
07-06-2018 11:09 AM
Looks like the issue is solved, but for future reference, there is a hidden gem for closing a VI and waiting until it has actually left memory. You can find it here:
vi.lib\VIServer\Close VI Reference and Wait Until VI Leaves Memory.vi
07-10-2018 03:34 AM
Thanks for your advice, i still trying to solve this problem...with all your recommended ways