LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop .NET DLL execution from caller VI

In my caller VI, I call a .net assembly DLL in back diagram using constructor. I want to if there is method to terminate DLL execution from caller VI. The DLL I called has a timeout of 30s and I don't wait that long to get the execution priority back to caller VI.

 

Any suggestion?

0 Kudos
Message 1 of 4
(3,410 Views)

Once LabVIEW passes off execution to some other component, like a DLL or a .NET assembly, it really has no control over it. It has no ability to abort or terminate that code path. You can verify this by trying to press the Abort button in the LabVIEW toolbar while the external function is executing. LabVIEW will hang trying to terminate execution.

 

Your best bet might be to call this method asynchronously from LabVIEW, so that even if it's hanging, the rest of your LabVIEW app doesn't have to wait. By calling asynchronously, I mean to do something like placing the function call in its own separate loop. To call the function, send a message to that loop via queue, notifier, user event or whatever. Then have that loop send some message back when the function returns, again via queue or something.

 

If you can't abort the DLL itself, you can at least ignore it and go about your business until it finally times out.

 

Another quicker option that can sometimes be appropriate is to call the function many times with a smaller timeout until it succeeds. So, for instance, don't call it with a 30 second timeout once, call it 30 times with a 1-second timeout. Then allow the user to abort the loop that's busy calling it whenever they like.

Jarrod S.
National Instruments
0 Kudos
Message 2 of 4
(3,400 Views)

That 30s timeout is in DLL, it's the reason why I want to terminate it from caller VI.

 

I tried to press 'Abort' button in Labview, but I think you are right. Labview has no control about DLL and need wait DLL finish execution.

 

But I want to know more about asynchronously, do you mean running two while loops at the same time? Any doc or links?

0 Kudos
Message 3 of 4
(3,373 Views)

Especially for the dotNet stuff, if the assembly does not support Async calling, then it becomes very difficult to implement this if not impossible. I have found it necessary to insure that I look for Timeout values in assembly calls as well as utilizing callback functions such that an event is generated at the end of the call. But not every assembly supports this. 

Something to bear in mind if you are writing assemblies.

 

Using duel loop designs would allow you to implement a call Asynchronously, but if the call 'hangs', you still would not be able to abort the execution.  However, if the call takes 'a while' (insert your definition of that here), you can code it such that your UI is still responsive, or other activities still take place.  

 

As far as examples, you can look for duel loop producer consumer architectures.  Many coders use these to run data acquisition  asynchronously so that there are not issues with buffer over runs and such.  


Paul
Message 4 of 4
(3,358 Views)