LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to allow cleanup actions to be taken by a reentrant clone before it is killed, when viewed via web server, because of a browser close?

Solved!
Go to solution

Here is a question I'm having to luck with.  I have a VI, set to be reentrant, which is published via the web server.  The main VI instance is never interacted with: it makes a clone every time someone navigates to the proper URL, and the user interacts with the newly created clone (never the main instance).  A clones is capable of configuring and calling instrument VI's when proper login credentials are entered, which results in browser popups that are controllable on the user's end (though only one user is ever doing this at a time. To clarify, multiple clones can be open simultaneously for login purposes, but only one user is ever interacting with the instruments, which aren't themselves reentrant). 

 

If the user clicks my custom logout button in their browser, it is trivial to close these other, independent instruments and clean up properly.  But if the user simply clicks the red X in their browser, there is no graceful shutdown and the instruments which the clone called stay open on the server, when they should be closing.

 

My experience so far:

 

No panel close? event seems to be triggered in the clone.  The clone simply ceases to be.

 

The remote_panel_connections property doesn't seem to work correctly in this instance (I haven't had any luck so far), since it is possible for more than one clone to be active, and the main parent that is spawning the clones stays running but isn't interacted with in any way.

 

What I Need:

A way for the clone VI to recognize that the user has closed their browser, and communicate that it is closing to all active VI's before terminating.

 

--------------

I would like to avoid forcing the instruments that the clone calls to poll constantly to see if the clone VI is present on the network.  If there is no other solution but this, I would appreciate a suggestion as to the least resource and code intensive way to implement this type of polling, as the instruments are really meant to be totally independent entities after they are called, rather than sub vi's. 

 

Thanks for any input, let me know if more information is needed.

 

0 Kudos
Message 1 of 4
(2,356 Views)

Hey MTdev,

 

Panel close? events cannot be triggered on a VI being viewed or controlled remotely. Some more information on that can be found in the help here:http://zone.ni.com/reference/en-XX/help/371361E-01/lvprop/vi_panel_closeq/.  My suggestion would be to set the Title Bar on the front panel of your remote VI to not be visible so that their only option for closing the window is to click the logout button.  Are you using Remote Front Panels(http://zone.ni.com/devzone/cda/tut/p/id/3277) to do this instrument control?  Using remote front panels allows you to manage a lot of the multiple people accesssing at the same-time type issues so it may be something to look into if you are not already using this method.  

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 4
(2,340 Views)
Solution
Accepted by topic author MTdev

@MTdev wrote:

A way for the clone VI to recognize that the user has closed their browser, and communicate that it is closing to all active VI's before terminating.

 


When a VI stops running, any reference like a queue becomes invalid also.  You could make use of this fact.  If your original clone VI could launch a second reentrant VI that stays alive, you could pipe all communication to the instruments via second VI using a queue created in the first.  When the first VI disappears, it will trigger an error in the waiting dequeue VI in the second (no polling is involved).  The second VI can then take whatever action required.

Message 3 of 4
(2,327 Views)

Thanks, the queue idea is something I hadnt thought of.  To clarify for the first response, I can get rid of the title bar on the popup windows from the main window, but the main browser instance will always have a way to close.  Plus, they could always have a computer restart or some other failure, which would mess up a system that relies entirely on a logout feature.  Breaking the VI into two and using queues is pretty much polling, but at least its simple and I don't have to insert code into my standalone instruments.  Thanks both of you for the replies.

0 Kudos
Message 4 of 4
(2,317 Views)