NI TestStand

Showing results for 
Search instead for 
Did you mean: 

Thread pausing

Go to solution



I have two threads running in parallel.

The first thread which is the MainSequence and the second one which is the new thread.

The first thread is used to send all the commands to the product.

The second one is used to ask the product if there is a problem or not on its Autotest every 5 secondes.

The fact is that if I send a command to the product at the same time as there is an Autotest, TestStand stop by telling that it is not possible to ask something to the product.


Can you please help finding any solution to pause the second thread when I need to send any command to the product ?


Best Regards



0 Kudos
Message 1 of 7

On any of the steps in either sequence that have communication to the product, you could use the Properties->Synchronization->Lock feature.  


There's an example based on the batch model, but the multithread aspect I think is applicable to you too.

Examples\Built-In Step Types\Synchronization Step Types\Synchronization Step Types - Lock.seq


I think I would add Lock/Unlock steps before and after your Autotest in the new thread.  In your MainSequence, I would use the Lock feature in the communication steps to look for the Lock name (say it's "comm").


Pulido Technologies LLC

Message 2 of 7

Thanks for you reply.

I don't think it's exactly what I need.

In fact, I would like to completly stop the Autotest thread execution and continue the MainSequence.

I made some trials with the "Lock" functionnality, but I cannot manage to do so.

Best Regards


0 Kudos
Message 3 of 7

It sounds like when MainSequence is communicating, you don't want your AutoTest thread communicating.  After MainSequence is finished communicating, do you want your AutoTest thread to communicate again?  


Locking will enable one thread to wait for another if a resource (in this case, the DUT) is being used by another thread.  


If you want your AutoTest thread to "completely stop" (I interpret this to mean stop running for the rest of the time), then you could (one of many possible ideas) set a FileGlobals flag in MainSequence that the AutoTest thread checks for and exits when the flag is true.


Pulido Technologies LLC

Message 4 of 7


Thank you for your help.

I already use a flag to definitely stop my Autotest running.

But in fact, what I want is just to pause the Autotest during some signal recording I need to do on the product.

So that the thread of my Autotest will wait the recording to be completed before continuing.

According to what you explained, it should be possible with the Lock Synchronisation, but I cannot manage with the TestStand exemple on my computer.

Could you please help me again ?

Best Regards


0 Kudos
Message 5 of 7
Accepted by topic author ThGO

Take a look at the attached files.  (For the sequence to work, you'll have to ensure that the two calls to go to the right path.)


AutoTest is set to run until the the AutoTestFlag is reset.  Both MainSequence and AutoTest call "" which is reentrant.  Both steps have the "Use Lock to Allow..." set with the name "lock".  


When you run MainSequence, you can see that each sequence takes turns running and displaying which sequence made the call.  


To experiment further, you can uncheck the "Use Lock to Allow..." options.  If you run MainSequence in this case, you'll see two instances of


In your specific application, for any communication step, just use the lock option with the same lock name across your different threads.


Pulido Technologies LLC

Message 6 of 7


0 Kudos
Message 7 of 7