Software Archive
Read-only legacy content
17061 Discussions

CVF dll under MTS

wfroese
Beginner
333 Views
I have a non-COM dll that I would like to run under MTS. It has only one exported entry point and lots of global variables. If I make a VB wrapper dll could the dll be reentered from a second thread before the first thread gets done? I am worried that multiple concurrent calls to the dll will get mixed together but I don't know if that happens. I have never made MTS things before. Will a second thread be blocked until the first thread is finished? Has anyone tried this? Any suggestions? Do I have to make a COM interface? Thanks everyone!
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
333 Views
If I make a VB wrapper dll could the dll be reentered from a second thread before the first thread gets done? I am worried that multiple concurrent calls to the dll will get mixed together but I don't know if that happens. Will a second thread be blocked until the first thread is finished?

Not automatically -- you have to take care about that. There are several blocking mechanisms provided by Windows (events, mutexes, critical sections). Basically, you have two options:

a) To rework your dll to be reentrant. This would require quite a lot of job; in general, all variables in reentrant Dlls have to be AUTOMATIC (there's a compiler switch), so there should be no global data -- and it's a pain to rework a program with lot of commons in this way. You'd also have to link with multithreaded libraries.

b) To simply disallow reentry while a calculation is still in progress. Here you can find a sample with named mutexes (it is referred to instances of an application, however the approach would work in your case also) -- just take care that you destroy the mutex just before return (otherwise, you'll be able to run calculation only once :-)) with CloseHandle.

I'm not familiar with COM so I can't tell you about that.

HTH

Jugoslav
0 Kudos
Reply