LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Launch a LabVIEW VI in the background from CVI

Solved!
Go to solution

Not sure if this is best posted in the LabVIEW or CVI forum...  

 

I need to launch a LabVIEW VI "in the background" from CVI.  In other words, I need to call a LabVIEW VI (that is built into a DLL) from CVI, and have the function call return immediately, while the called VI finishes executing in the background.  

 

I have had success making this kind of asynchronous call from within LabVIEW using a Start Asynchronous Call Node.  This works as it is supposed to: The asynchronous call node finishes executing immediately, while the called VI runs in the background.

 

The problem arises when I build this into a DLL, and call it from CVI.  If I build the DLL with debugging enabled, and then step through the code, pausing the code right after the asynchronous call, the background VI executes successfully.  But if I run all this full speed, the asynchronous VI does not execute.  

 

I would suspect that since the DLL call returns before the asynchronous VI can finish, the asynchronous VI is killed when the DLL call returns.  Obviously I need the background/asynchronous VI to finish after control is returned to the CVI code.  Am I doing this wrong?  Is there a better way?

 

My code is highly integrated and probably not useful to post.  If it would help to write up an isolated example to post, I'll do that, but only if others can't identify a better/different approach.

 

Thanks in advance,

Joe

 

 

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

Figured it out...  This thread ends up addressing a similar issue from a different perspective.  The problem is that when LabVIEW detects that the last front panel has been closed, it closes.  Since my VI was being run without an open front panel, when the original calling VI ends and returns to CVI, LabVIEW prematurely kills the VI that I ran asynchronously.  

 

I fixed the problem by displaying a dummy front panel, and moving it off screen.  It's important to note that this dummy front panel must be launched before the calling VI (the one that makes the asynchronous VI call) ends.  Otherwise LabVIEW will kill execution of the asynchronous VI.  

 

It seems like this isn't ideal behavior... Can anyone shed some light on why LabVIEW behaves this way, or perhaps a better way of doing this?

0 Kudos
Message 2 of 3
(3,272 Views)
Solution
Accepted by JoeDG

Hey JoeDG,

 

Yes, as Evan mentioned in the thread you referenced, this is a characteristic of LabVIEW. As he said, for execution to continue there must be at least one front panel open. While I understand that this causes some problems for VIs that are running without a front panel, it sounds like the workaround you implemented is the best way to go. I apologize that you had to take an indirect route to achieve your end goal, but I'm glad that things are up and running for you now.

 

Best,

 

 

 

 

0 Kudos
Message 3 of 3
(3,253 Views)