From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Asynchronous Call - collect OR forget?

Solved!
Go to solution

Hi all,

 

I want to optimize one of my LabView procedures. Let's say that I've got 2 VIs that return the same values, but use differend data sources. I'd like to launch both of them and simply collect the result from the faster one.

I figured I could do this by running both VIs asynchronously and polling a global variable, but I was hoping that there is a better solution.

If I "Wait on asynchronous call" for both VI, I'll wait for the slowest one to finish. Is there a way to check if VI has finished its job without running into "wait on asynchronous call"?

 

Thanks in advance!

 

Tomasz

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

Hi Tomasz,

 

run both subVIs in parallel and let them write their results to the same notifier or queue.

 

In your MainVI you just use the first value coming from the notifier/queue by setting it's timeout to -1…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,523 Views)

In this case, I would probably go with the notifier.  You could possibly also go with a User Event.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 6
(2,517 Views)

It is a better idea than polling a global variable, but then again, after reading the queue I'll probably destroy it right away, invalidating its reference used by the slower VI. It should check if it's still valid then.

I was hoping for something else, but this will do as well. Thanks!

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

Hi Tomasz,

 

each reference of the notifier/queue can be closed without destroying the notifier/queue! Infact this is standard behaviour as written in the help

 

What "something else" are you looking for?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(2,510 Views)

Indeed you are right! My bad! 🙂

 

Thanks again!

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