From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Application freezes even with parallel loops

Solved!
Go to solution

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?

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

You should post code if you want people to help.

Glad to answer questions. Thanks for any KUDOS or marked solutions 😉
0 Kudos
Message 2 of 4
(3,568 Views)
Solution
Accepted by topic author B_Strange

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:

CLFN.png


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 3 of 4
(3,565 Views)

@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:

  • It does not store any global data, such as global variables, files on disk, and so on.
  • It does not access any hardware. In other words, the code does not contain register-level programming.
  • It does not make any calls to any functions, shared libraries, or drivers that are not thread safe.
  • It uses semaphores or mutexes to restrict access to global resources.
  • It is called by only one non-reentrant VI."

 

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