Archived: Background Execution of LabVIEW NXG Applications

NI does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.

Contents

What has changed?


With the release of LabVIEW NXG 2.0, the behavior of the Close button on your built application has changed. The Close button no longer results in your code possibly terminating before it is finished. Instead, you must handle the “Window”:Close event, treating the Close button like any other control that can cause your application to shut down. The application exits when your code is finished.

 

The Close button on a LabVIEW NXG 2.0 application.

 

In the figure above, the Close button, caught by the “Window”:Close event, and the Stop button are handled in the same event case, simply passing a True to the conditional terminal of the while loop, ending the application.

 

New in LabVIEW NXG 2.1 - The Continue Background Execution warning dialog

 

If you don’t handle a “Window”:Close event and shut down your application, the LabVIEW NXG 2.1 runtime will present a Continue Background Execution? warning dialog after a short delay.

If continuing to run after the Panel is closed is normal for your application or if your shutdown code takes longer than the warning delay (<=10 seconds), you can suppress the warning message by unchecking the “Background execution warning” checkbox in the Runtime group of your application properties in the Configuration Pane.

 

How is this different from LabVIEW 2017 and earlier?


The difference is that the Close button no longer results in the termination of running VIs. In LabVIEW 2017 and earlier you can place shutdown code in the Panel Close? filter event but the code must complete within the event case because the runtime could terminate running VIs as soon as the event case finishes. In other words, the Panel Close? filter event only delays the actions that terminate running VIs. 

In the LabVIEW 2017 figure above, the subVI “1” within the Panel Close? event will run but the application could exit as soon as the event case finishes. SubVI “2” may never run. Additionally, in the case of an application with multiple windows, this behavior only applies to the last open window, making shutdown even more complicated to implement and troubleshoot. The new behavior in LabVIEW NXG 2.0 would allow all your code to complete and it is consistent in the editor, in an application, and even in an application with multiple windows.

 

Summary


Beginning in LabVIEW NXG 2.0, clicking the Close button no longer results in the termination of running VIs but you must handle the “Window”:Close event and ensure that it initiates shutdown of your application just as a Stop or Cancel button on your panel would.

In LabVIEW NXG 2.1 applications, a warning dialog will appear after a short delay if your application has not finished executing. If you allow your application to continue running without an open panel, you will have to use task manager to terminate your application.

 

Was this information helpful?

Yes

No