Re: ATL COM Server exits when client exits
From: Ben Rush (kwendex_at_yahoo.com)
Date: 07/06/04
- Next message: Taurus Sun: "ATL Debug Build and Unicode Release MinSize Fail"
- Previous message: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- In reply to: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- Next in thread: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- Reply: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 06 Jul 2004 01:09:33 -0500
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: Taurus Sun: "ATL Debug Build and Unicode Release MinSize Fail"
- Previous message: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- In reply to: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- Next in thread: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- Reply: Ganesh Okade: "Re: ATL COM Server exits when client exits"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|