NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Control execution of different threads in TestStand

Solved!
Go to solution

Hi All,

 

I'm trying to control multiple threads within a sequence file.  I though I would be able to use the following

 

ThisContext.Thread.Execution and then terminate/ break/ etc. as desired.

 

I start a new threaded sequence in process setup.  I want it to close the original sequence and then display a message which the user clicks.

 

I have two problems:

 

1. ThisContext.Thread.Execution is identical in both threads.  Shouldn't it be different?

 

2. Everything shuts down when I terminate the thread and not just the sequence which called the new thread.  I imagine this is directly related  to 1.

 

Does anyone know how to close a thread from another thread?

 

Thanks,

Sean

0 Kudos
Message 1 of 4
(5,845 Views)
Solution
Accepted by SeanJ

Hi Sean

 

1.) Thats clear. An execution may contain more than one Threads

 but a thread can belong to just to only one execution.

 

2.) In my opinion it is not easy to terminate, if i am honest dont know if this is really possible !

 if you have to terminate in side a thread i always use a new execution instead a thread.

 It seems Ray had the same problem

http://forums.ni.com/t5/NI-TestStand/In-TestStand-how-can-a-stop-a-Thread/m-p/54455

 

Regards

 

Juergen 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 2 of 4
(5,827 Views)

1. ThisContext.Thread.Execution is identical in both threads.  Shouldn't it be different?

 

You said you started a new Thread therefore the Execution will be the same, you would need to start a New Execution instead.

 

2. Everything shuts down when I terminate the thread and not just the sequence which called the new thread.  I imagine this is directly related  to 1.

 

When you terminate, you are terminating an execution and hence all threads in that exection.

 

 

 

Regards
Ray Farmer
Message 3 of 4
(5,826 Views)

Why do you want the second thread to close the first one? Do you need it to execute some code first? Why not just let the first execution exit?

 

You can use a sequence call step configured to New Execution or New Thread to call a sequence with a new execution or thread. You should uncheck the option on the subpanel of settings for the New Execution/Thread call that says "Wait at end of sequence" or something similar so that the first execution can exit without waiting for the second one.

 

I do not recommend using terminate as that will be asynchronous, I'm not sure what you are trying to accomplish by using terminate, it seems like you could just let the original thread exit on its own or using one of the synchronization step types to synchronize things if you need the new thread to do something first.

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 4
(5,808 Views)