01-11-2011 08:30 AM
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
Solved! Go to Solution.
01-12-2011 12:54 AM
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
01-12-2011 12:57 AM
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.
01-12-2011 10:00 AM
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