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: 

LabVIEW DLL

Solved!
Go to solution

Hello,

I have a DLL written on c++ that I'm calling from labView, the DLL does a lot of operations that take time, the code is working well, but when I'm running it labview freeze until the DLL operation finish.

 

i'm using labview : 21.0

 

Thanks for your helps. 

 

0 Kudos
Message 1 of 5
(862 Views)
Solution
Accepted by topic author Krmbab

Hi Krmbab,

 


@Krmbab wrote:

I have a DLL written on c++ that I'm calling from labView, the DLL does a lot of operations that take time, the code is working well, but when I'm running it labview freeze until the DLL operation finish.


Yes, LabVIEW will freeze as long as the DLL call doesn't return. What else can it do?

So what is the problem, when your DLL works as expected?

 

Suggestions:

  • Try to handle UI in parallel to your DLL call, but do the DLL call in a different thread (VI properties) if supported by your DLL.
  • Change the DLL code to return faster to the caller, maybe by splitting the "big" function call into several smaller ones!?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(842 Views)
Solution
Accepted by topic author Krmbab

If the functions you try to call do not access global variables or other global resources such as hardware registers or similar, your function should be multithreading safe and you should be able to select in the Call Library Node to execute the function in any thread. Then LabVIEW will call the function in whatever thread it is running in at the time of executing your caller VI diagram, rather than forcing a context switch to the UI thread to safely call your DLL function. The UI thread is the single canonical root thread in LabVIEW that guarantees that nothing that might be multithreading unsafe, including updating the LabVIEW GUI, can run into concurrency trouble. So if your function locks that thread up for intense calculations, LabVIEW can't claim it to keep refreshing its GUI and the application appears to have been locked up until your function returns control to LabVIEW.

 

If your DLL is multithreading safe is something you as the developer of it should be able to assess. If it is you can safely set the Call  Library to execute in any thread. If it isn't and you set it anyhow to execute in any thread you can get weird results and/or crashes.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 5
(840 Views)

it exactly whate heppen with me, i forget to check run the function in eny thread, thank you very much for your help and your suggestions 

0 Kudos
Message 4 of 5
(818 Views)

very nice explanation, it gives me the best practices for my future DLL code, thank you very much for your assistance and your time.

0 Kudos
Message 5 of 5
(815 Views)