Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: How to stop a Tid(Cmd)TCPServer while clients are connected?
| Subject: | Re: How to stop a Tid(Cmd)TCPServer while clients are connected? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Wed, 5 Dec 2007 10:50:11 |
"Chris Ueberall" <CUeberall@web.de> wrote in message
news:475693dc$1@newsgroups.borland.com...
> I'm updating some GUI controls (a TShape [shpClientConnected] and a TMemo
> [memClients]):
Since TId(Cmd)TCPServer is a multithreaded component, you can't safely
access UI controls from any of its events (especially OnDisconnect in
particular) without using TThread.Synchronize() or TIdSync.Synchronize() (or
any other manual synchronous technique). However, performing such a
synch'ed operation will deadlock if the server is already in a shutdown
state within the main thread. The main thread is blocked waiting for the
server, and the synch'ed operation is blocked waiting for the main thread,
thus blocking the server. Instant deadlock. So you have to either shut
down the server from a separate thread, or else use asynchronous operations
that do not block the event handlers.
Gambit
none