Stop All Threads From Executing in Teststand

Updated Aug 21, 2024

Environment

Software

  • TestStand

This article demonstrates how to stop all TestStand threads from executing.
This approach can be applied when executing a SubSequence in a new thread or execution, and you need to ensure that all threads are stopped by the time the MainSequence finishes.

There are two Runstate methods that can be used to achieve this functionality: It is recommended to use the TerminateAll() method, since this ensures that all SubSequences will run through their Cleanup steps before stopping. AbortAll() will stop all threads immediately.

To use either of these methods, place a Statement step in your MainSequence where all threads should be stopped and set the expression to one of the above methods.

TerminateAll.PNG

Attached is an example sequence file (created in TestStand 2023 Q4). This sequence file consists of the following functionality:
  • Inside the MainSequence, a SubSequence is started in a new thread.
    • The SubSequence consists of an infinite While Loop.
  • While the SubSequence is running, the MainSequence waits for 3 seconds.
  • After 3 seconds, the Runstate.Engine.TerminateAll() method is called to trigger all threads to run through Cleanup and stop.

Attachments