indy9在程序关闭时出现terminate thread timeout的BUG解决办法

INDY9线程有BUG,在退出程序的时候会报错:terminate thread timeout(终止线程超时)。

解决办法:

procedure TForm1.DisconnectAll;
var
List: TList;
I: Integer;
begin
List := IdTCPServer1.Threads.LockList;
try
for I := 0 to List.Count - 1 do
begin
try
TIdPeerThread(List.Items[I]).Connection.Disconnect;
except
on E: Exception do
begin
TIdPeerThread(List.Items[I]).Stop;
end;
end;
end;
finally
IdTCPServer1.Threads.UnlockList;
end;
end;

 

DisconnectAll;  // 先执行
IdTCPServer1.Active := False;

相关文章:

  • 2021-06-17
  • 2021-09-08
  • 2022-12-23
  • 2021-09-02
  • 2021-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-12-09
  • 2022-12-23
  • 2021-08-31
相关资源
相似解决方案