LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How is it possible to make sure that LV uses the same thread for several threadsafe DLL calls?

Hello,
 
i have a thread safe DLL and most functions are called from serveral threads from the LV apllication without problems.
 
In case of an error i have to call an error handler function in this DLL (like WinAPI: GetLastError()) from the same thread which has called the function that failed before.
 
I can't use the user interface execution because some functions need a long execution time and i don't want to balk the user interface.
 
All other executions than the user interface execution have more than one thread and in most cases the DLL function calls were executed from different threads - so the error handling doesn't work...
😞
 
Any idea?
 
Thanks for your help!
0 Kudos
Message 1 of 4
(2,229 Views)

Hmmm....

How about wrapping all of your dll calls in a single VI (or an Action Engine ) and make sure the VI's thread is NOT set for "Same as caller".

"Threadconfig.vi" (sp?) will also let you dictate the number of threads associated with an execution system. Set your target thread for "1".

Not sure on the above.

Please correct me if this is wrong!

Ben

Message Edited by Ben on 07-19-2007 08:26 AM

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 4
(2,225 Views)
Hello,

You could also use a callback sturcture, if you have control over the source code of the DLL.

Create a LabVIEW DLL with functions that you want to have called on specific events in the DLL in question. Get the function pointer to the function in the labview dll with window api function and pass those pointers to the dll in question. The dll can now call a function in your labview dll notifying you of an error and where it happened.

This technique can be very usefull to reduce the need to poll a dll for new data.

Regards,

André
Regards,
André (CLA, CLED)
0 Kudos
Message 3 of 4
(2,209 Views)

Thanks your your help. I was not sure that this really could solve all my problems.

but i've realized it now with a new wrapper function (added to the DLL) which calls all necassary other functions implicitly.

I think it's the simplest way....

 

 

0 Kudos
Message 4 of 4
(2,158 Views)