04-29-2015 04:05 PM
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
Solved! Go to Solution.
04-29-2015 05:10 PM
04-29-2015 05:13 PM
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.
06-29-2017 03:05 PM
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.
06-30-2017 08:58 AM
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.
07-03-2017 09:29 AM
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.
08-09-2017 08:18 AM
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.