03-22-2013 11:31 AM
I want to programatically check whether a VI is running. I tried to use the "ExecutionState" property, but this did not work for me. My problem is that my definition of running does not match the execution state property’s definition of running:
My Definitions
· Running = Some element of this VI is currently executing (run arrow looks like this: )
· Reserved = This VI is a sub VI of a running VI, but this VI is not actually running (run arrow looks like this: )
· Idle = This VI is in memory but is not running or reserved (run arrow looks like this: )
Execution State property definitions
· Running = Some element of this VI is currently executing OR this VI is a sub VI of a running VI (run arrow looks like this or like this )
· Idle = This VI is in memory but is not running (run arrow looks like this: )
Since each VI's front panel displays a running arrow when that VI is running and a reserved arrow when that VI is reserved, there must be some way to programatically distinguish between these two states. I hope that this distinction is exposed to programmers.
03-22-2013 12:13 PM
If you could give us a description of why you want to do this, someone may have an alternative way of doing it. 🙂
03-22-2013 12:38 PM
I am trying to debug a large application. This application dynamically launches many VI's that run in their own threads. When the application shuts down it is supposed to close all of these dynamic VI's, but sometimes it does not. I want to know which VI's are still running. My problem is made more difficult by the fact that most of the VI's are reentrant.
03-22-2013 01:09 PM - edited 03-22-2013 01:12 PM
Got it. Did you check whether you get Running on Top level or Running?.
03-22-2013 01:13 PM
03-22-2013 03:38 PM
Have you tried running the Desktop Execution Trace? It is really good at identifying resources that aren't getting closed.
03-23-2013 12:58 PM - edited 03-23-2013 12:58 PM
You should also go vote for this idea - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Need-a-way-to-visualize-VI-call-chain-hierarchy/idi-p/...
Just to expand on P@Anand's suggestion, because it is a good one - you can obtain references to all the VIs and check their state, and then open the BDs of those which are Run Top Level and manuallly inspect where the code is actually stuck.
Note that if your top level VIs are the ones which are reentrant, you will need to open a reference to the clone, and that's not listed in the All VIs In Memory property, although there are some ways around that. You can try to open N references in a loop using MyVI.vi:# as the VI name and ignore those which return an error, but you should note that the numbers don't necessarily start from 1 and that NI might close up the option to get the clone references like that.
You could also try closing the main VI to unload it and then opening a new one and looking at the Unopened SubVIs hierarchy, which should list all of the clones. I'm assuming that if the main VI is unloaded, only the clones which are still running will still be in memory, but that might change if you have classes (which don't unload) and I haven't actually tried this myself.