Click here to Skip to main content
15,914,014 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: click over a balloon tip Pin
Peter Molnar9-Dec-03 12:27
Peter Molnar9-Dec-03 12:27 
GeneralRe: click over a balloon tip Pin
Member 7044079-Dec-03 21:05
Member 7044079-Dec-03 21:05 
GeneralRe: click over a balloon tip Pin
Peter Molnar10-Dec-03 1:18
Peter Molnar10-Dec-03 1:18 
GeneralI want a function called on thread exit. Pin
8-Dec-03 9:39
suss8-Dec-03 9:39 
GeneralRe: I want a function called on thread exit. Pin
Robert Kuster8-Dec-03 13:14
Robert Kuster8-Dec-03 13:14 
GeneralRe: I want a function called on thread exit. Pin
Matthew Busche8-Dec-03 23:44
Matthew Busche8-Dec-03 23:44 
GeneralRe: I want a function called on thread exit. Pin
Peter Molnar9-Dec-03 12:21
Peter Molnar9-Dec-03 12:21 
GeneralRe: I want a function called on thread exit. Pin
Matthew Busche11-Dec-03 10:44
Matthew Busche11-Dec-03 10:44 
Peter,

Thanks for your reply. I actually started to do this and only just now discovered that this only works for RUN-TIME dynamic-linking of a DLL. (I.e., where you use the LoadLibrary call just like you said.) I saw some sample code on how to use LoadLibrary and GetProcAddress to call a single simple function from a DLL, but I'm not exporting a single simple function, I'm exporting a handfull of C++ concrete and abstract classes (along with all their numerous member methods and overloaded operators). It is not clear to me how you'd use run-time linking for such a library. Supppose Peter, you inherited from one of my abstract base-classes, then when you wrote your constructor, how would you call my base class constructor that is exported from my DLL?

And even if it's possible, my whole objective is to make my software as easy as possible to use. I certainly wouldn't want my users to have to jump through any flaming hoops to call a base class constructor or call the "=" operator for a class.

Here's a thought. What if I had two libraries? Library ALPHA has all my user visible software and could be built arbitrarily for either dynamic or static linkage. If built as a DLL it would be expected to be used with load-time dynamic-linkage. DLL BETA has nothing in it but a DllMain. Now, here's the trick: suppose DLL ALPHA secretly does a LoadLibrary call on BETA via some singleton constructor found in ALPHA. This singleton is instantiated the first time a user of ALHPA references resources that require thread initialization and cleanup activities. Then, I would presume that every subsequent thread spawn and delete would cause this DllMain in BETA to be invoked, would it not? I presume also that DllMain in BETA could invoke methods defined in ALPHA (to effect thread initialization and cleanup.)

I'm going to investigate this idea further and maybe try it out.

Let me know if I misunderstood the implications of your email. I've been battling this silly problem for a week now. If I don't come up with a better solution soon, I'll have to simply publish a threadCleanup method that must be called by users of my library on thread exit, but I really don't want to have to do this.

Once again, thanks sincerely for your help.
Matt

GeneralRe: I want a function called on thread exit. Pin
Matthew Busche11-Dec-03 11:08
Matthew Busche11-Dec-03 11:08 
GeneralERROR Pin
mitil203904823048-Dec-03 9:26
mitil203904823048-Dec-03 9:26 
GeneralRe: ERROR Pin
John M. Drescher8-Dec-03 9:30
John M. Drescher8-Dec-03 9:30 
GeneralRe: ERROR Pin
mitil203904823048-Dec-03 9:34
mitil203904823048-Dec-03 9:34 
GeneralRe: ERROR Pin
John M. Drescher8-Dec-03 9:38
John M. Drescher8-Dec-03 9:38 
GeneralRe: ERROR Pin
Christian Graus8-Dec-03 9:40
protectorChristian Graus8-Dec-03 9:40 
GeneralRe: ERROR Pin
John M. Drescher8-Dec-03 9:45
John M. Drescher8-Dec-03 9:45 
GeneralRe: ERROR Pin
Christian Graus8-Dec-03 9:38
protectorChristian Graus8-Dec-03 9:38 
GeneralRe: ERROR Pin
mitil203904823048-Dec-03 9:41
mitil203904823048-Dec-03 9:41 
GeneralRe: ERROR Pin
Christian Graus8-Dec-03 9:42
protectorChristian Graus8-Dec-03 9:42 
GeneralRe: ERROR Pin
mitil203904823048-Dec-03 9:45
mitil203904823048-Dec-03 9:45 
GeneralRe: ERROR Pin
mitil203904823048-Dec-03 9:52
mitil203904823048-Dec-03 9:52 
GeneralRe: ERROR Pin
Christian Graus8-Dec-03 10:57
protectorChristian Graus8-Dec-03 10:57 
GeneralRe: ERROR Pin
mitil203904823049-Dec-03 8:38
mitil203904823049-Dec-03 8:38 
QuestionHow to bypass Outlook 2002 Security Object Model Guard Pin
Kevin McFarlane8-Dec-03 6:14
Kevin McFarlane8-Dec-03 6:14 
GeneralQuestion: Serial Plotting Pin
foghorn8-Dec-03 5:42
foghorn8-Dec-03 5:42 
GeneralRe: Question: Serial Plotting Pin
JWood8-Dec-03 10:48
JWood8-Dec-03 10:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.