BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to prevent com server app from being terminated

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
Torsten Anders
Guest





PostPosted: Mon Mar 07, 2005 12:47 pm    Post subject: How to prevent com server app from being terminated Reply with quote



My com server app should do some lengthy work in the background, but must
also be able to run as stand alone. If the app is started manually
everything is ok, but if started by ole automation is seems to be terminated
directly after form create has finished, but form close and form close query
aren't called. The client app just makes
Bind()
SendData()
Unbind()
I must call Unbind directly, but how can I prevent the server from
termination or how and where termination is done.

May thanks in advance!
Torsten


Back to top
JJ
Guest





PostPosted: Mon Mar 07, 2005 4:42 pm    Post subject: Re: How to prevent com server app from being terminated Reply with quote



When an ole object is created, its reference count is incremented by 1. This
reference count is decremented when the object is released.

COM will only unload your object when this reference count is 0. This is the
reason why your stand-a-lone server stays open when it is started manually
and closes when it is loaded by COM.

As for how to keep it open when loaded by COM, I guess you can artificially
add one more to your reference count when you return the object to the
client although I don't recommend it. If you need to do some cleanup before
shutting down, then it's probably better to put your shutdown code somewhere
else.

Hope this help.
Jeff www.ruamkwamkid.com


"Torsten Anders" <anders (AT) tasoft (DOT) org> wrote

Quote:
My com server app should do some lengthy work in the background, but must
also be able to run as stand alone. If the app is started manually
everything is ok, but if started by ole automation is seems to be
terminated
directly after form create has finished, but form close and form close
query
aren't called. The client app just makes
Bind()
SendData()
Unbind()
I must call Unbind directly, but how can I prevent the server from
termination or how and where termination is done.

May thanks in advance!
Torsten





Back to top
Torsten Anders
Guest





PostPosted: Tue Mar 08, 2005 2:54 am    Post subject: Re: How to prevent com server app from being terminated Reply with quote



Thanks, hor your help. I had the idea too and increase the ref counter now
when the program is started in automation mode and decrease the counter when
all the work is down. But what's really confusing: Why the FormClose method
of the main form isn't called?
Torsten

"JJ" <chingwaah (AT) hotmail (DOT) com> schrieb im Newsbeitrag
news:422c846b (AT) newsgroups (DOT) borland.com...
Quote:
When an ole object is created, its reference count is incremented by 1.
This
reference count is decremented when the object is released.

COM will only unload your object when this reference count is 0. This is
the
reason why your stand-a-lone server stays open when it is started manually
and closes when it is loaded by COM.

As for how to keep it open when loaded by COM, I guess you can
artificially
add one more to your reference count when you return the object to the
client although I don't recommend it. If you need to do some cleanup
before
shutting down, then it's probably better to put your shutdown code
somewhere
else.

Hope this help.
Jeff www.ruamkwamkid.com


"Torsten Anders" <anders (AT) tasoft (DOT) org> wrote in message
news:422c4d49$1 (AT) newsgroups (DOT) borland.com...
My com server app should do some lengthy work in the background, but
must
also be able to run as stand alone. If the app is started manually
everything is ok, but if started by ole automation is seems to be
terminated
directly after form create has finished, but form close and form close
query
aren't called. The client app just makes
Bind()
SendData()
Unbind()
I must call Unbind directly, but how can I prevent the server from
termination or how and where termination is done.

May thanks in advance!
Torsten







Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.