01-18-2011 05:51 AM - edited 01-18-2011 05:51 AM
Can I kill the monitoring thread from out of the cleanup of the main sequence when there is a normal pass of the test. So I get a passed in my normal test sequence instead of 'terminated'.
01-18-2011 09:53 AM
Rather than killing the thread it is better to tell the thread to exit and then wait for it to exit. One way to do this is to pass a boolean variable into the thread by reference, then in your cleanup set the boolean variable to true (which the monitoring thread checks and exits when it's true). Then in your next cleanup step wait for the thread using a TestStand Wait step, or have the sequence call step that launches the new thread set to "wait for thread at the end of the sequence".
Hope this helps,
-Doug
01-19-2011 01:47 AM
Doug, I like this approach but how to pass the variable by reference? Will this method shut down a thread where resides an infinite loop?
01-19-2011 02:32 AM
When you place a variable in the Parameters Tab of a Sequence, with it highlighted, right mouse click and you should find a setting 'by reference', select this.
Actually, I thought this was the default setting.
01-19-2011 04:32 AM
How I set this parameter to true? Do I need to make a sequence call to the same thread? How to do this?
01-19-2011 09:58 AM
When you call the sequence you specify a variable to pass for the parameter. In this case you might want to create a local variable called monitoringThreadShouldExit and pass that. Then when you want the monitoring thread to exit, you just do:
Locals.monitoringThreadShouldExit = true
You monitoring thread should then be checking Parameter.ShouldExit (or whatever you called the parameter) in its loop condition and not loop if it's set to true.
-Doug
01-20-2011 02:11 AM
Doug, I tried ur method but the thread keeps running. I put a statement in my main sequence cleanup that states 'monitoringThreadShouldExit == True'. I passed that variable when I started the monitoringThread. How to debug this?
01-20-2011 09:38 AM
Your thread needs to check the variable and stop looping to let itself complete. It depends on what your monitoring thread is doing for how best to accomplish this. Does your thread loop in a VI or DLL or in the sequence itself?
-Doug
01-20-2011 01:02 PM
In a VI. But does the thread check the referenced parameter when its running or only at the start?
01-21-2011 01:29 AM
My fault. 🙂 I used == instead of = to assign a value to the boolean. Tnx guys!