11-25-2015 10:56 AM
I've developed an application that controls a digital fluorometer using a C++ DLL (provided by the vendor) over a USB connection. I specifically set up the architecture as QMH because long scans on the fluorometer can take several seconds and I want the user to be able to control the front panel while the hardware runs in parallel. For some reason, when the hardware control loop is tied up with its scan, the front panel locks up. If I click anywhere in the window, I get the "...Not Responding" message in the toolbar until the scan is finished. While this is happening, memory and CPU usage remain about the same so I don't believe it's tying up system resources. Also, Windows responds normally.
I believe the DLL is being called at a level that affects the entire vi and once the DLL call is made, every LabVIEW process gets put on hold. Am I off base with this assumption? If not, how would one circumvent this situation?
Solved! Go to Solution.
11-25-2015 11:19 AM
You should post code if you want people to help.
11-25-2015 11:20 AM - edited 11-25-2015 11:22 AM
Yes - your problem is with the LabVIEW UI thread/root loop. There is a very good article about it here.
Your Call Library Function node is set to 'Run in UI thread' which means that it will run in the same thread as any UI actions or anything else that requires the UI thread. This means no other UI actions can occur while your C++ DLL function is running - it's blocking the thread from continuing.
You need to find out whether or not the DLL is thread safe, and if it is, change the calling method of the C++ DLL in the call library function node to 'run in any thread'.
You can tell the difference from the colour of the CLFN:
11-25-2015 11:30 AM
@Sam_Sharp wrote:
Yes - your problem is with the LabVIEW UI thread/root loop. There is a very good article about it here.
Your Call Library Function node is set to 'Run in UI thread' which means that it will run in the same thread as any UI actions or anything else that requires the UI thread. This means no other UI actions can occur while your C++ DLL function is running - it's blocking the thread from continuing.
You need to find out whether or not the DLL is thread safe, and if it is, change the calling method of the C++ DLL in the call library function node to 'run in any thread'.
This is a good anwer. Thanks. That is one big hairy monkey off my back!
I also found this tidbit here:
"Before you configure a Call Library Function Node to run in any thread, make sure that multiple threads can call the function simultaneously. In a shared library, code can be considered thread-safe when: