LabVIEW Development Best Practices Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Managing Asynchronous calls

Solved!
Go to solution

Hello all,

 

I have recently developed an application where I have the main VI running and keep it responsive meanwhile different VIs are launched asyncrhonously.

My proposed solution was this:

* Launch VIs using the "Start Asynchoronous call" function and wire a Message Queue as an input to those.

* The asynchronous VIs will run until finishing and will return a Message queue to the main VI.

* In this way I avoided the use of the "Wait on asynchronous call" function which "stops" the application waiting for the async VI to finish its execution.

 

Using Message queues maintains the main VI responsive and able to get results from the async VIs in a timely manner.

 

Could this be considered as a good idea or is there a better way to do it?

 

Dinnova_0-1643864280862.png

Sincerely,

 

Julio Aguayo

Dinnova Ingeniería S de RL de CV

NI Partner System Integrator

 

 

 

 

 

0 Kudos
Message 1 of 6
(2,457 Views)
Solution
Accepted by topic author Dinnova

Generally this approach with queues/notifiers etc. as a means of communication with async VIs was the recommended way by NI last time I looked.

 

However, in the past I have used async VIs only when starting up and managing communication to different pieces hardware AND not knowing in advance, how many devices I should communicate to. So I devised an ini process that reads generic hardware connection data (however many there are) and then call the same async VI in reentrant mode within a loop over the number of devices.

 

If you have a distinct known number of processes that should work asynchronously, I'd say make a normal VI per process, drop all of those onto the block diagram and do away with the async calls. LabVIEW is inherently asyncronous in all process, except for wire-induced sequentiality and other handshaking methods, like occurences, notifiers. See my dilletantically created symbolic block diagram.

Message 2 of 6
(2,437 Views)

I've created a library for this called Futures for LabVIEW.

 

It's based on the concept of futures/promises which is how many languages handle asynchronous responses.

 

I thought there was a video - but I can't find it now!

 

There is a basic user guide on github at https://github.com/WiresmithTech/Futures-For-LabVIEW/blob/main/docs/user-guide.adoc though and the toolkit is on VIPM: https://www.vipm.io/package/wiresmith_technology_lib_futures/

 

under the hood - it uses the same concepts as you describe though so you are certainly on the right track.

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 3 of 6
(2,429 Views)

I'm sure your next version will be a vim, so we don't need the variant-to-data 😉

0 Kudos
Message 4 of 6
(2,404 Views)

Thanks for answering Comrade,

 

I very much appreciate your comments.  I became intrigued about your INI process as it may very well be a strategy I could employ moving forward.  If you have more details about it those will be appreciated.

 

Sincerely,

 

Julio

0 Kudos
Message 5 of 6
(2,391 Views)

Thanks for sharing James,

 

First time I hear about Futures, so I downloaded into my LabVIEW and gave it a quick try.  I'm very enthusiastic to use it more widely, however I may have to sleep it some days before I can better unsderstand how can I effectively apply it.  If you have practical examples where you have used it maybe I will come to a conclussion faster.

 

 

 

Dinnova_0-1644037621889.png

 

Sincerely,

 

Julio.

0 Kudos
Message 6 of 6
(2,386 Views)