LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable Thread Local Storage in a DLL generated by application builder?

I used application builder to build a DLL. I had VC6 codes to load the DLL explicitly. Every time I called LoadLibrary, the handle returned is the same.
I want each thread within my application to have its own copy of the DLL's variable. How to do it? Thanks.
0 Kudos
Message 1 of 7
(3,434 Views)
HermanChan wrote:

> I used application builder to build a DLL. I had VC6 codes to load the
> DLL explicitly. Every time I called LoadLibrary, the handle returned
> is the same.
> I want each thread within my application to have its own copy of the
> DLL's variable. How to do it? Thanks.

I don't think you can do that. A DLL is always loaded into a process
only once. There isn't such a thing as a separate DLL handle between
threads. Thread Local Storage (TLS) is as far as I know something
different which needs to be taken care of in the DllMain function of
the Dll. But for a LabVIEW generated DLL you have no way of changing
the behaviour of the LabVIEW provided Dll entry function.

Rolf Kalbermatter
Message 2 of 7
(3,434 Views)
Is there any setting in VI, like VI properties or inside the application builder, to achieve that?
0 Kudos
Message 3 of 7
(3,434 Views)
You might try making the VIs renterant (vi properties >> execution )before you build the application.
0 Kudos
Message 4 of 7
(3,434 Views)
I tried.
When I made VIs renterant, the front panel didn't popup in my MFC application.
0 Kudos
Message 5 of 7
(3,434 Views)
No! TLS is a rather tricky thing and if you don't know exactly how to work with it you cause more problems than you try to solve. As far as I know it also depends on the compiler and its runtime libraries how you can use that.
As you can see I have not really bothered even in my C programming to do that.
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 7
(3,434 Views)
Yes, reentrant VIs do not update their front panels and are definitely not meant to be used as GUI.
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 7
(3,434 Views)