COM server running multiple threads .... How to close them? 
Author Message
 COM server running multiple threads .... How to close them?

Hi,

I have a COM server (in-proc) which has one COM object (Free threaded).  The
COM object has one interface method that creates a thread to do some work
when called.  At any one time the object can have a number of threads
running.  I want to be able to 'gracefully' kill all my running threads when
FinalRelease() is called on my object.  At the moment I don't signal any of
the threads that the object is closing and I get a lot of memory leaks etc.
Whats the best way to signal multiple threads to end in this situation?

regards,
C.



Sun, 23 May 2004 06:38:13 GMT  
 COM server running multiple threads .... How to close them?
I'm not sure that this is the best way, but one way that works and is
efficient is to have your threads wait on (among other things) a 'quit'
event.
Then when you want to quit, signal that event and wait for all threads to go
away.
I think that this is the standard way to handle this.

Salim.


Quote:
> Hi,

> I have a COM server (in-proc) which has one COM object (Free threaded).
The
> COM object has one interface method that creates a thread to do some work
> when called.  At any one time the object can have a number of threads
> running.  I want to be able to 'gracefully' kill all my running threads
when
> FinalRelease() is called on my object.  At the moment I don't signal any
of
> the threads that the object is closing and I get a lot of memory leaks
etc.
> Whats the best way to signal multiple threads to end in this situation?

> regards,
> C.



Mon, 24 May 2004 03:04:26 GMT  
 COM server running multiple threads .... How to close them?
Or in the case where the thread has a message loop (and not
MsgWaitForMultipleObjects), call:

    ::PostThreadMessage(threadId, WM_QUIT, 0, 0);

But if the thread doesn't have a message loop, using an event as described
by Salim is preferrable.
Dirk


Quote:
> I'm not sure that this is the best way, but one way that works and is
> efficient is to have your threads wait on (among other things) a 'quit'
> event.
> Then when you want to quit, signal that event and wait for all threads to
go
> away.
> I think that this is the standard way to handle this.

> Salim.



> > Hi,

> > I have a COM server (in-proc) which has one COM object (Free threaded).
> The
> > COM object has one interface method that creates a thread to do some
work
> > when called.  At any one time the object can have a number of threads
> > running.  I want to be able to 'gracefully' kill all my running threads
> when
> > FinalRelease() is called on my object.  At the moment I don't signal any
> of
> > the threads that the object is closing and I get a lot of memory leaks
> etc.
> > Whats the best way to signal multiple threads to end in this situation?

> > regards,
> > C.



Mon, 24 May 2004 03:25:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to run automation server as multiple instance?

2. Lifetime of EXE COM server that uses DLL COM server

3. STA OOP Server used by multiple threads

4. How to force COM EXE to run multiple processes

5. Server Using CSocket and Multiple Threads

6. Multiple activation of a COM server

7. Problem w/multiple instances of out of process COM server

8. How to enable and create multiple instances of a COM server in ATL

9. running instance of COM object in ATL/MFC server

10. Passing COM pointers to new thread to run SQL query in ATL

11. Passing COM pointers to new thread to run SQL query in ATL

12. run com object in worker thread

 

 
Powered by phpBB® Forum Software