NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Single Stepping with Multiple Threads

I have been having problems using the TestStand debugging tools (specifically single stepping) when running a sequence with Multiple Threads.

I have a device that generates events that I need to monitor continuously, so I run a loop that monitors the events in a different thread. The sequence works well when I run it, but I cannot use the debugging tools.

The problem occurs when the loop is inside a test module as opposed to inside the sequence itself.

I have reproduced the problem with a simple sequence and a VI. I'm attaching 3 examples that use multiple threads. The problem occurs in example number 3. You must create a boolean station global variable called FinishThread to run examples 2 and 3.

Have you ev
er seen a problem like this before? I need to be able to debug my sequences. Any ideas?

Thanks,

Marcela.
0 Kudos
Message 1 of 4
(3,741 Views)
The problem is that in order for an execution to break, all threads must be at a breakpointable location. In otherwords, all threads must be between steps. There is however a way around this.

Using the TestStand API property Thread.ExternallySuspended, you can tell the teststand engine to treat the thread that is running your VI as if it were an already suspended thread. When a thread is externally suspended, TestStand no longer requires it to be between steps in order for the execution to break.

The way you use the property, Thread.ExternallySuspended, is to set the property to true before the code in your vi starts running and then set it to false immediately before returning from your vi (You can get a reference to the thread from SequenceContext.Thread). If y
ou set the property to false while the execution is at a breakpoint, the vi will block on the call to set the property until the execution in teststand continues. For more information on Thread.ExternallySuspended, see the TestStand API Help section on this property.

Hope this helps,
Douglas Melamed
National Instruments
Message 2 of 4
(3,741 Views)
Thanks!

It works like a charm!
0 Kudos
Message 3 of 4
(3,741 Views)
I found this to work in LabView, but I need it to work in LabWindows. I emulated the same commands, but it doesn't seem to have any effect. Am I missing something?
0 Kudos
Message 4 of 4
(3,741 Views)