10-07-2025 01:05 PM
I have multiple subpanels with instances of the same vi running (set to "Preallocated clone reentrant execution") inside them (started via Start Asynchronous Call). I want to know if a vi in a subpanel has stopped execution. I have tried getting a reference to the inserted vi and checking the execution state property (see attached snipped) but it always returns "running" once a vi has been started, even if the vi has finished execution.
Solved! Go to Solution.
10-07-2025 01:13 PM - edited 10-07-2025 01:17 PM
When you open the reference using Open VI Reference to the subVI to insert into the subpanel, started with Start Asynchronous Call, you need to set the appropriate flags. See the list here:
https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/open-vi-reference.html
The Help for Start Asynchronous Call indicates you need to use either 0x80 or 0x100. 0x80 specifically says "Use this when you do not need to know when [...] the VI returns." So that leaves option 0x100, which includes info on using Wait on Asynchronous Call:
So, retain the reference you used when you started it, then use a Wait on Asynchronous Call to wait until that VI is done waiting. You can also add a timeout via a right-click menu if you just want to check the status without waiting on it. I assume you can call it in a loop if you want to poll it instead of waiting on it.
Your method didn't work because "Running" actually means "VI is reserved for execution by one or more active top-level VI's" (see documentation here). I'd argue the naming of that property is pretty poor, as it's been a point of confusion multiple times. At least back in 2014 there wasn't a way to do that- and, as far as I know, there has been very little (if any) changes to core VI server functionality in the last decade.
10-07-2025 01:21 PM
And of course Paul Cardinale has a solution that attempts to work around this:
(According to the documentation, Wait on Asynchronous Call is the "right" way to do what you're trying to do, but Paul's method might help you as well, being a more general solution.)
10-08-2025 06:32 AM
thanks, I may have found a way to (somewhat) achieve what I need:
It's not a perfect solution, tough. Each time this check is run, return values (if any) must be handled and the vi refrence must be invalidated, because subsequent calls with a reference to a stopped vi will generate timeout errors again (as if the vi was running).
10-09-2025 02:06 AM
Paul Cardinale's solution does not work for me (at least not out of the box). I assume this is because it checks for any error code, which would also match for a vi that is not running (but I'll need to look deeper into this)
10-09-2025 03:04 AM
I changed Cardinale's solution slightly::
If the vi is not running the invoke node will generate error code 1000.
This works in labview but not with the lv runtime engine, meaning its not a viable solution for my problem.