Code modules that TestStand calls can launch dialog boxes or perform other time-consuming operations. In these cases, you might want code modules to periodically check whether TestStand terminated or aborted the parent execution of the code module so the code module can stop gracefully and allow the parent execution to terminate or abort. For example, you might want a code module to dismiss a dialog box or cancel a long acquisition and immediately return to TestStand when execution of the code module terminates.

In addition, you might want code modules to permit TestStand to suspend the parent execution thread at a breakpoint without requiring the code module to first return to TestStand. For example, you might want TestStand to be able to suspend an execution at a breakpoint while a code module launches a dialog box that waits for user input.

Use the Execution.InitTerminationMonitor and Execution.GetTerminationMonitorStatus methods to determine whether the execution receives a request to terminate or abort the execution. The termination monitor only recognizes requests to terminate or abort while monitoring, so a code module that executes in a Cleanup step group of an already terminating execution monitors for a subsequent request to terminate the step or abort the execution.

Because the Allow Break While in Code Modules option on the Execution tab of the Station Options dialog box is enabled by default, TestStand suspends the execution thread at a breakpoint even if other threads are executing code modules. Therefore, you do not need to use the Thread.ExternallySuspended property unless you disable the Allow Break While in Code Modules option.

Use the Execution.GetStates method to determine whether the execution is suspended.

LabVIEW

As an alternative to the Execution API, you can use the following VIs to enable VIs that TestStand calls to determine whether the execution receives a request to terminate or abort the execution:

  • TestStand - Initialize Termination Monitor
  • TestStand - Get Termination Monitor Status
  • TestStand - Close Termination Monitor

The Termination Monitor only recognizes requests to terminate or abort while monitoring, so a code module that executes in a cleanup step group of an already terminating execution monitors for a subsequent request to terminate the step or abort the execution.

Refer to the VIs in the following directory for examples of how to use these VIs:

  • <TestStand Public>\Examples\Demos\Computer Motherboard Test\LabVIEW

Because the Allow Break While in Code Modules option on the Execution tab of the Station Options dialog box is enabled by default, TestStand suspends the execution thread at a breakpoint even if other threads are executing code modules. Therefore, you do not need to use the TestStand – Set Thread Externally Suspended VI unless you disable the Allow Break While in Code Modules option.

LabWindows/CVI

As an alternative to the Execution API, you can use the TS_CancelDialogIfExecutionStops function the TestStand Utility Functions driver provides to enable code modules that launch dialog boxes to verify whether the execution that called the function has stopped. Refer to the dialog box code in the following example source file for examples of how to use this function:

  • <TestStand Public>\Examples\Demos\Computer Motherboard Test\CVI\Computer Motherboard Test Sequence.c