NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

In TestStand, how can a stop a Thread.

Hi,

I have a main sequence that runs for ever providing the user hasn't pressed the stop button and the Power hasn't failed.
The Stop button is on a dialogbox in a sequence which is launched in a new thread. The dialogbox is just a MessageBox step type.

If the Power Supply fails, the loop in the MainSequence is terminated but the execution of the sequence file is not stopped because the DialogBox Sequence is still running and the user will have to press the STOP button to complete the termination of the execution.

Is there a way to stop the execution of the Dialog sequence from the MainSequence without having to press the STOP button.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 1 of 6
(6,786 Views)
Hello Ray,

There's always a way to do something in TestStand =0) !

You can use the method "Execution.Terminate" or "Execution.Abort". These methods will terminate (cleanup step groups will execute) or abort (cleanup step groups will NOT execute) ALL the threads belonging to the Execution object. Therefore, after calling this method, your MainSequence AND subsequence will both terminate or abort since they belong to the same execution object.

If you only want to abort/terminate a particular subsequence, you'll need to launch it in a New Execution instead of in a New Thread. Remember to store the execution reference in a variable because you'll need it when invoking the Execution.Abort or Execution.Terminate methods.

Note: You can control an
execution object but not a thread object. In other words, you cannot break, abort nor terminate an individual thread but rather all threads belonging to an execution object.

Let me know if you have any questions.

Regards,

Carlos Leon
Message 2 of 6
(6,786 Views)
By the way, there's a great document discussing when to run a sequence in a New Execution vs in a New Thread:

http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/2af8f285c67ee1fa86256a55007ad975?OpenDocument
0 Kudos
Message 3 of 6
(6,786 Views)
Here is your sequence file, modified to use a new execution. Note that the selected execution settings prevent a new execution window from appearing.
Message 4 of 6
(6,786 Views)
Hi James,

Thanks for the modified sequence file. Although I did have to make a slight adjustment, as the MainSequence didn't actual stop when the STOP button was pressed.

But running the sequence in a new execution rather than a new thread did the trick.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 5 of 6
(6,786 Views)
Hi Carlos,

Thanks for the info.

Ray
Regards
Ray Farmer
0 Kudos
Message 6 of 6
(6,786 Views)