From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Launching an asynchronous thread from SequenceFileLoad or ProcessSetup callback.

Hi everyone. I would like to launch an asynchronous thread from a callback, either the SequenceFileLoad callback or the ProcessSetup callback in my client sequence file.  I want to be able to stop the thread from the coorisponding ending callbacl (SequenceFileUnload, etc).

 

The code to start and stop the thread all works (Using a singleton queue to sten the command to stop the loop in the LabVIEW code) and the Thread starts and runns in the callback like it is supposed to.  However the callback never actually ends and moves onto the main execution until the thread stops.  I want to be able to start the thread and have it run continuiously (it talks to some hardware) throught the entire testing loop rahter than having to start and stop it for each UUT which would be the case if I just put it in MainSequence. 

 

I am sure there must be a way to start a thread and have the callback end, while leaving the thread running, but I am missing it.  Suggestions?

 

Thanks!

 

Gregory Osenbach, CLA
Fluke
0 Kudos
Message 1 of 3
(4,099 Views)

So let's look at threads and executions.  Threads are contained in executions.  Executions cannot complete until all threads complete.  SequenceFileLoad and SequenceFileUnload are executions that that end once the file is loaded or unloaded.  So although you can spawn a new thread from SequenceFileLoad the execution will not complete until that thread completes.  The problem with this is that you cannot start your test now because you have a thread open.  So my suggestion is to do it in the ProcessSetup and ProcessCleanup.

 

Next concern, how are you spawning the thread?  Are you doing it in a subsequence or are you using the asynchronousVI step type?  I recommend a subsequence.  If you use a thread then you need to uncheck the option to Automatically Wait for the Thread to Complete at the End of the Current Sequence checkbox in the Sequence Call Advanced Settings.  That way your execution can go on it's merry way after ProcessSetup completes but you still have a thread out there. 

 

Another thing to keep in mind.  I would use a FileGlobal as my flag to trigger.  Obviously a parameter or local will be out of memory once you get to ProcessCleanup.

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 3
(4,087 Views)

Just want to add that if you really do want to start a new thread from a SequenceFileLoad callback, what you could do is use a new execution instead. You can even make it hidden. Starting a new execution will allow the original execution to complete (assuming you've unchecked the "Automatically wait at end of sequence" option).

 

-Doug

0 Kudos
Message 3 of 3
(4,067 Views)