|Subject:||Re: Shutdown TidHTTPServer when last response served|
|Posted by:||Remy Lebeau (TeamB) (firstname.lastname@example.org)|
|Date:||Fri, 5 May 2006|
"Eric Carlson" <email@example.com> wrote
> D7 Ent/Latest Indy 9. I have a form with the server on and the user
> could close it at any time. When they do, I send a message to another
> window (service based) which activates its server. This works most
> of the time, but I'm getting some timing funnies - sometimes the service
> version never starts.
Please show your actual code.
Keep in mind that a service may be running in another desktop. You can't
send window messages across desktops. If all you are trying to do is notify
the service, without sending any parameters to it, then you should consider
using the ControlService() function instead. If your service is based on
the VCL's TService class, then you can override the virtual
> In the OnClose method of the first form, I set active := false and do
> the SendMessage. Could it be the server doesn't close because its
> servicing some requests?
Setting the Active property to False waits for all active connections to be
> In other words, can I count the number of currently serviced requests
> (threads?) and only continue the handover if they are zero?
They will always be zero when the Active property setter exits, unless a
timeout occured. In which case, an EIdTerminateThreadTimeout exception will
be thrown. TIdTCPServer has a TerminateWaitTime property for controlling
that timeout value.
Shutdown TidHTTPServer when last response served posted by Eric Carlson on Fri, 5 May 2006