S
SuKiDelphi
Unregistered / Unconfirmed
GUEST, unregistred user!
当 IdTCPServer1 和 IdTCPClient1 连接上时, 如果用户关了Server(IdTCPServer1), Client (IdTCPClient1)未关, IdTCPClient1 出错: terminatethreadtimeout的异常
procedure TRMServers.FormDestroy(Sender: TObject);
var
I : Integer;
begin
with IdTCPServer1 do
begin
if Active then
begin
with Threads.LockList do
try
for I:=Count-1 downto 0 do
begin
try
TIdPeerThread(Items).Connection.WriteLn('End');
//TIdPeerThread(Items).Connection.CloseWriteBuffer;
TIdPeerThread(Items).Connection.Disconnect;
TIdPeerThread(Items).Data := nil;
TIdPeerThread(Items).Free;
//TIdPeerThread(Items).FreeOnTerminate:=True;
//TIdPeerThread(Threads.LockList.Items).Free;
except
end;
end;
finally
Threads.UnlockList;
end;
Active:=False;
end;
end;
end;
procedure TRMServers.FormDestroy(Sender: TObject);
var
I : Integer;
begin
with IdTCPServer1 do
begin
if Active then
begin
with Threads.LockList do
try
for I:=Count-1 downto 0 do
begin
try
TIdPeerThread(Items).Connection.WriteLn('End');
//TIdPeerThread(Items).Connection.CloseWriteBuffer;
TIdPeerThread(Items).Connection.Disconnect;
TIdPeerThread(Items).Data := nil;
TIdPeerThread(Items).Free;
//TIdPeerThread(Items).FreeOnTerminate:=True;
//TIdPeerThread(Threads.LockList.Items).Free;
except
end;
end;
finally
Threads.UnlockList;
end;
Active:=False;
end;
end;
end;