05-04-2012 04:50 PM
I am using a DLL to communicate with a device (spectrometer to be exact).
The device can be a bit unreliable and occasionally freezes while the DLL is running.
My question is: how can I enable a DLL call to timeout after a limit is reached?
(This would also give me the ability to abort a test without having to wait for the device to return the last measurement)
I've considered using VI server to make an asynchronous call to the VI that calls the DLL and stopping the execution of that VI if it times out but I was hoping there was a simpler solution. Thanks in advance.
05-04-2012 05:01 PM
There is no way to abort a DLL call without killing the VI that makes the call, so the VI server approach may be necessary if you can't fix the DLL. I did something somewhat like this to handle an unstable ActiveX component and it worked well, although in that case the problem was that the ActiveX component tended to crash on its own and I didn't want it to take out my entire application.
05-04-2012 05:11 PM
Yea, basically the DLL tends to freeze sometimes which freezes the entire application.
05-07-2012 06:43 PM
Hi GollumGTH,
The VI Server option seems to be appropriate, as there doesn't seem to be any efficient way to accomplish this task. You can refer to this forum post where other customers were encountering the same issue.
http://forums.ni.com/t5/LabVIEW/Call-Library-Function-node-timeout/m-p/427324
I hope this information helps.
Regards,
06-29-2017 03:07 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 10:07 AM
Hi SirLogan,
Thanks for posting on the forums! I see that the original post was made in 2012, so if you wanted to get more visibility for your workaround, you might consider creating a new forum post.
Thanks!