Internet Direct (Indy) Version 9.0.2 Beta
|
property OnDisconnect: TIdServerThreadEvent;
Note: Do not call Synchronized method in the OnDisconnect event handler. Only inherited Notification calls are safe for use in OnDisconnect.
This is important because OnDisconnect is called for active client threads when the server sets Active to False. Using synchronized methods in OnDisconnect can result in a deadlock condition, caused when the thread is suspended while the method is executing in the main VCL thread.
TIdTCPServer will detect the deadlock condition, but a timeout error will be raised while trying to terminate the active threads. Use Thread.Notification to act on the notification that a component is being inserted or removed. For example, if a component has object fields or properties that contain references to other components, it can check the notifications of component removals and invalidate those references as needed.
Assign a TIdServerThreadEvent event handler procedure to OnDisconnect to allow responding to the event notification.