 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Torsten Anders Guest
|
Posted: Mon Mar 07, 2005 12:47 pm Post subject: How to prevent com server app from being terminated |
|
|
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
|
Posted: Mon Mar 07, 2005 4:42 pm Post subject: Re: How to prevent com server app from being terminated |
|
|
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
|
Posted: Tue Mar 08, 2005 2:54 am Post subject: Re: How to prevent com server app from being terminated |
|
|
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 |
|
 |
|
|
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
|
|