Re: ATL COM Server exits when client exits
From: Ganesh Okade (ganeshokade_at_sunlux-india.com)
Date: 07/07/04
- Next message: Andrew Walker: "Re: breaking changes from ATL 7.0 to 7.1 ? Problem with GetMessage()"
- Previous message: Martin Ortiz: "Re: why is my hook function so slow???"
- In reply to: Ben Rush: "Re: ATL COM Server exits when client exits"
- Messages sorted by: [ date ] [ thread ]
Date: 7 Jul 2004 12:32:52 -0700
Ben,
Thanks again for your reply. For now, I have implemented my first
alternative (i.e. a dummy application holding on to the COM server)
and it seems to be working fine. The dummy application is a background
task with no windows and runs on system startup.
Any alternative and cleaner method of implementation is welcome
from experts.
Regards,
Ganesh Okade
www.sunlux-india.com
Ben Rush <kwendex@yahoo.com> wrote in message news:<nsfke09vk8itjdi2vk87cei6ukiafhdj1d@4ax.com>...
> Ganesh,
>
> >Alternatively, I was wondering if I could create a dummy client
> >which will make a connection to the COM server and will always be
> >running "holding" the COM server from exiting. I know it is possible,
> >but would this be a good programming practice.
>
> As far as the second part of your question, is it a "good programming
> practice", I'm not sure. But the functionality you speak of is how COM
> cross-apartment communication occurs. When a remote activation request
> for a COM object is made through ORPC channels, the COM essentially
> connects with the correct COM apartment to call CoMarshalInterface on
> the requested interface (once it has been fully brought to life). This
> API returns what is called a stub manager which holds onto the object
> through IUnknown. The stub manager increments the ref count by 1 when
> it holds onto the remoted object, but maintains an internal reference
> count for each outstanding outer-apartment reference. When it detects
> all references are gone, it terminates and decrements its counter by
> 1, thereby removing itself and the object (given that it has no other
> outstanding references). All of this is pre-XPSP2.
>
> What all of this means is that COM already does this - so its
> possible. Potentially one could recommend to tred with caution,
> though, as doing something to short-circuit the COM's garbage
> collection capabilities could result in some very hard-to-debug code.
>
> One has to ask, though, how are you going to make sure that the
> object holding onto your object isn't deleted? Are you going to
> implement it as a service?
>
> >Alternatively, can I
> >make the COM server itself make some kind of a virtual connection to
> >itself so that the reference count is always greater than zero
> >preventing the application from exiting.
> > Thanks in advance for your valuable time.
> >
>
> This sounds like a more confusing version of the previous idea you
> had. Perhaps I'm missing something?
>
> >> Ben Rush
> >> http://my.mindvision.com/~ben/spoutlet/spoutings.html
>
> Ben Rush
> http://my.mindvision.com/~ben/spoutlet/spoutings.html
- Next message: Andrew Walker: "Re: breaking changes from ATL 7.0 to 7.1 ? Problem with GetMessage()"
- Previous message: Martin Ortiz: "Re: why is my hook function so slow???"
- In reply to: Ben Rush: "Re: ATL COM Server exits when client exits"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|