NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Terminate and Exit UI Upon Single Button Click

What's a simple way of Terminating All, then exiting a UI application with a single button? I'm curious how to know when the Terminate All is really done so I can exit the app and it won't prompt me with the "executions are currently running" dialogue.

 

I'm using something similar to the Simple User Interface Example UI with a sequential model and I use the TestUUTs entry point so it repeats until the user clicks "Exit". I'd like this single button to terminate TestStand and close the UI.

 

I'm thinking something like...

  1. User clicks Exit Button. Button event triggers IEngine.TerminateAll method.
  2. Wait until some event which indicates Terminate All is complete and triggers the ApplicationMgr.Shutdown method.
    How? Is there a way to know the process model execution has ended perhaps? Maybe I can use End Execution event callback, but how do know the execution ID of the process model? Another better way?
  3. The ApplicationMgr_ExitApplication event will fire indicating it's safe to close the application so it will triggers my code to actually close references and the UI.

Links:

TestStand Help Shutting Down the Engine

Forum Post TestStand AP Terminae All Notification

0 Kudos
Message 1 of 4
(3,667 Views)

What about using the time limits?

Time Limits.PNG

You can set it to automatically terminate on Exit and basically get this behavior. The trick is that your sequence needs to respond appropriately to termination (e.g. any long-running tests need to use the Termination Monitor API).

 

There are also time limits and options for Terminating and Aborting, so you can trade off closing down with an increasing degree of urgency for the possibility of not running clean-up code and leaving instrument handles open.

 

Hope this helps!

Trent

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 2 of 4
(3,613 Views)

Thanks for your reply. Interesting idea; I hadn't thought of using the Station Options.

However, I'm still a bit confused on how to best initiate the exit without getting a prompt saying do you really want to exit with current executions still running.

 

Maybe something like would be OK? I tried it successfully with nothing very obviously bad happening.

Screen Shot 2019-07-31 at 11.11.13 AM.png

0 Kudos
Message 3 of 4
(3,591 Views)

You mean the "Incomplete Executions" prompt? I'm not aware of any way to get around that... You need to make sure this button terminates all executions (and that they're done terminating, which is where the time limits come in handy) before you fire the exit command.

 

-Trent

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 4 of 4
(3,575 Views)