When executing automated test sequences in NI TestStand, it is often necessary to run a concurrent monitoring thread that continuously checks for an emergency stop (E-stop) condition. Examples include a user-initiated stop request from the operator interface or an external stop signal received from a PLC. Upon detecting an E-stop event, the test system should safely terminate sequence execution and transition to the Cleanup step group.
Directly terminating an execution or modifying a parent sequence context from an asynchronous thread is generally not recommended. Such actions can interrupt normal execution flow, prevent proper report generation, and cause failures in Process Model plugins or other post-execution activities.
This article describes an approach for implementing an asynchronous monitoring thread that communicates E-stop status through a File Global variable. The main execution thread then performs a controlled transition to the Cleanup step group through the SequenceFilePostStep callback. By ensuring that execution control remains within the primary sequence context, this method helps preserve Process Model integrity and supports orderly shutdown of the test sequence.
While this approach provides a reliable mechanism for handling E-stop events, it is important to note that TestStand offers multiple supported methods for gracefully terminating an execution. The technique presented in this article represents one possible implementation and is not intended to be an exhaustive list of all available solutions.