TestStand Debugging Tools Have Problems When Running Multiple Threads

Updated Jan 11, 2023

Reported In


  • TestStand

Issue Details

I am running some sequences in parallel threads. If the execution reaches a breakpoint while there is at least one external code module (e.g. LabVIEW VI, DLL) that is still running in a separate thread, the debugging tools (i.e. Step Into, Step Out, Step Over, Resume) are disabled. When all the external code modules running in different threads stop running, the debugging tools become enabled and I can use them.

What is happening and how can I use the debugging tools while running multiple threads?


In order for an execution to break, all threads must be between steps. In other words, the execution cannot break while one of its threads is calling a module. It must wait for the module to return. 

There is a way around this by using the TestStand API property Thread.ExternallySuspended, you can tell the TestStand engine to treat the thread that is running your code module as if it were an already suspended thread. When a thread is externally suspended, TestStand no longer requires it to be between steps for the execution to break.

Use the TestStand Engine API in your external module to set Thread.ExternallySuspended to equal to True before the code in your module starts running and then set it to False immediately before returning from your module (this is shown in the example under Related Links). You can get a reference to the Thread object from the Sequence Context (i.e. SequenceContext.Thread).

Additional Information

Note: If you set the property Thread.ExternallySuspended to False while the execution is at a breakpoint, the code module will block on the call to set the property until the execution in TestStand continues.

It is recommended to use the Thread.ExternallySuspended property within code modules that perform a lengthy operation or wait an indeterminate period of time (e.g. show a dialog box, have an internal while loop). For more information on Thread.ExternallySuspended, refer to the TestStand API Help section on this property or see the example linked below.