LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to dynamically load any number of VIs and spawn a new thread for each

Hi,

 

I'm trying to spawn several TCP listening threads, the number of which is dynamic based upon a configuration file which is read at runtime. With with the included code, I am attempting to open and call these listening threads from a for loop, thinking I could run through all the calls I need to make and be finished. However, since the subVI I'm calling (wait_for_and_process_messages.vi) runs a continuous while loop, the for loop in the parent VI does not continue as it is waiting for the first call to finish. 

 

How can I design this to simply spawn off a thread each time I call the subVI and continue? The idea is to allow the number of threads be dynamic so it is not so easy compared to knowing the number of needed threads ahead of time. However, I do need to feed data to each call's nodes so I can't just use the "run" method unless there's a way to feed data to the nodes while using "run."

 

dynamicthreadattempt.JPG

 

 

 

0 Kudos
Message 1 of 3
(3,098 Views)

Check out this Nugget.

 

It contains code that should help you get started.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 3
(3,090 Views)

You might also want to check out this example:

 

%LABVIEW%\examples\viserver\runvi.llb\DateServerUsingReentrantRun.vi

 

I came across this some weeks ago when I checked out how to dynamically call a re-entrant VI.

_________________________
CLA
0 Kudos
Message 3 of 3
(3,078 Views)