LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timeout on a DLL Call

Solved!
Go to solution

Hello,

 

Does anyone know if there is a way to force a DLL call to timeout?  I have a DLL that I've wrapped with some VIs but on some of the methods, there seems to be an internal hardcoded timeout which I would like to reduce but right now I'm blocked until the DLL call completes so I have to wait for that internal timeout which is ~35sec.  Thanks.

 

- Will



I saw my father do some work on a car once as a kid and I asked him "How did you know how to do that?" He responded "I didn't, I had to figure it out."
0 Kudos
Message 1 of 7
(4,496 Views)
Solution
Accepted by topic author blackburnite
There's no way to interrupt a call to a DLL. A call to a DLL never times out; the DLL function must finish in order for execution to continue.
0 Kudos
Message 2 of 7
(4,485 Views)

Yea that's what I assumed, just wanted to check, every now and then someone has an interesting hack/shortcut.  I'll have to see if I can get the source.



I saw my father do some work on a car once as a kid and I asked him "How did you know how to do that?" He responded "I didn't, I had to figure it out."
0 Kudos
Message 3 of 7
(4,480 Views)

 I've made somewhat of a workaround; using the Application Control functions, I use my main VI to run a separate VI (make sure Wait Until Done is false). The main via writes some data to a file, starts the new VI (which runs the DLL function), and waits for 3 seconds for a response file to be written. If it doesn't find the response file within that time, it force closes the separate VI. There's probably a better way to communicate data from one VI to another, but writing files was easy for me to whip together.

0 Kudos
Message 4 of 7
(3,959 Views)

If your DLL really freezes inside the DLL function call this is not likely to solve anything. When you attempt to close a VI that is stuck in an external code call (Call Library Node or Active X/.Net method) then LabVIEW will signal the VI to abort, but not having any control about the DLL context in which the function is stuck, it will determine that the thread is currently executing outside it's own control and after a short delay show the threaded "Resetting VI" dialog, waiting for the external code to eventually return anyhow.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 7
(3,944 Views)

You are correct. It takes a while for my program to freeze, so I had thought the problem was resolved. Since that didn't work, I built the separate vi into an executable, and used the System Exec function to run the executable. If the executable doesn't write the file in that time, I use the System Exec function to force close it.

0 Kudos
Message 6 of 7
(3,927 Views)

I've done something similar in the past, though not specifically for this case.

 

I used the async call node instead of VI server methods to start the wrapper VI and then polled the wait on async call node which you can configure to timeout.  If the wrapper VI was finished running, the wait node would return with no errors, if it was still running, error 123 would be returned on timeout.



I saw my father do some work on a car once as a kid and I asked him "How did you know how to do that?" He responded "I didn't, I had to figure it out."
0 Kudos
Message 7 of 7
(3,857 Views)