本文整理自网络,侵删。
我们常用IdTCPServer1.Active := false;来关闭Idtcpserver,但这样会出卡机,并且操作也不会成功,后来,我改为这样:
var i: integer; AList: TList;begin AList := IdTCPServer1.Contexts.LockList; try for i := AList.Count - 1 downto 0 do begin TIdContext(AList.Items[i]).Connection.Disconnect; end; finally IdTCPServer1.Contexts.UnlockList; end;
也就是说不要用IdTCPServer1.Active := false;这种方式来断开Idtcpserver。
相关阅读 >>
Delphi 时间与相关类型(2) - tdate、ttime、ttimestamp
更多相关阅读请进入《Delphi》频道 >>