LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to force DLL running in one thread when in executable

Hi there !

I've got a DLL which is built 'thread safe' that I must call very often.

So I've got to call it out of the UI Thread, but I also nned to force an execution system to allocate only thread so that the DLL code runs fine.

I've been able to do so modifying the LabVIEW .ini file like this :
ESys.StdNParallel=-1

ESys.other1.Normal=1
ESys.other1.Bgrnd=1
ESys.other1.High=1
ESys.other1.VHigh=1
ESys.other1.TCritical=1

 

using \vi.lib\Utility\sysinfo.llb\threadconfig.vi

 

It does work fine in the development environnement.

How to force the run-time engine to adopt the same behavior when I will release my application ? (exe)

CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 1 of 5
(4,290 Views)

I never needed to ensure that a DLL runs only in a single thread. However, I had problem in the past with a wrongly

configured Call Library Function which was used to operate on a DLL. The dll was coming with a driver pack from a company,

and when I was running my VI including this DLL call, it slowed down my GUI as hell!

 

The solution was simply to configure the Call Library Function node NOT to use the UI thread.

So if you go into the config settings of your Call Library Function Nodes, set the thread usage to "Run in any thread" instead of "Run in UI thread".

 

But I guess in your case it is still not an option, since the DLL requires a totally separate thread...? Lets wait for someone understanding the situation deeper, I am willing to learn more about this topic...

 

edit: this tutorial: http://www.ni.com/tutorial/3009/en/  says if you have a "thread-safe" dll, you should just use the above settings as I described. Could you test it?

0 Kudos
Message 2 of 5
(4,261 Views)

Hi Blokk,

 

My CLF is already using 'Run in any thread' setting.

In this case, the execution system of the VI calling the CLF run the DLL in any of the threads held by the Exec (up to 24 thread per Exec System). My DLL performs I/Os and calculs which are troubled when called from several threads : then it is not thread safe.

 

In that case, the only way to make it work is to force the Exec System to run only 1 thread (see procedure exposed in my first post). Then it works fine.

However, this setting applies to LabVIEW.exe.

 

How to apply it to the exe I'll generate ?

Placing the corresponding lines of the labview ini file in my exe ini file wil be enough ?

CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 3 of 5
(4,256 Views)

Hmm, ok, I am a bit confused about how threads are handled in case of DLL calls 🙂

Also, I have no idea how to distribute those config settings in case of EXE application. Maybe you could try some insane settings just for testing at that config file parameters, so you can clearly see when they take effect running your EXE on another PC?

0 Kudos
Message 4 of 5
(4,253 Views)

@zyl7 wrote:

Placing the corresponding lines of the labview ini file in my exe ini file wil be enough ?


This should work, but note that the name of the INI file is the same as the name of your EXE, rather than LabVIEW, and the section name inside the INI file should also match your EXE name.

0 Kudos
Message 5 of 5
(4,236 Views)