Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi IdTCPServer: RSTerminateThreadTimeout (Terminate Thread ...) (https://www.delphipraxis.net/57141-idtcpserver-rsterminatethreadtimeout-terminate-thread.html)

hardy1234 18. Nov 2005 07:05

Re: IdTCPServer: RSTerminateThreadTimeout (Terminate Thread
 
Pardon

while THread.Count > 0 do begin

Puhbaehr 18. Nov 2005 07:19

Re: IdTCPServer: RSTerminateThreadTimeout (Terminate Thread
 
Mh... :?

Hatte ich nicht erwähnt, dass...

Zitat:

Zitat von Puhbaehr
...hier (in der Unit IdTCPServer) in dieser Prozedur:

Delphi-Quellcode:
procedure TIdTCPServer.TerminateAllThreads;
const
  LSleepTime: Integer = 250;
var
  i: Integer;
  LThreads: TList;
  LTimedOut: Boolean;
begin
  // Threads will be nil if exception happens during start up, such as trying to bind to a port
  // that is already in use.
  if Assigned(Threads) then begin
    // This will provide us with posibility to call AThread.Notification in OnDisconnect event handler
    // in order to access visual components. They can add notifications after the list has been
    // unlocked, and before/while TerminateThreads is called
    LThreads := Threads.LockList; try
      for i := 0 to LThreads.Count - 1 do begin
        with TIdPeerThread(LThreads[i]) do begin
          Connection.DisconnectSocket;
        end;
      end;
    finally Threads.UnlockList; end;
    // Must wait for all threads to terminate, as they access the server and bindings. If this
    // routine is being called from the destructor, this can cause AVs
    //
    // This method is used instead of:
    //  -Threads.WaitFor. Since they are being destroyed thread. WaitFor could AV. And Waiting for
    //   Handle produces different code for different OSs, and using common code has troubles
    //   as the handles are quite different.
    //  -Last thread signaling
    // ThreadMgr.TerminateThreads(TerminateWaitTime);

    if not TIdThreadSafeList(Threads).IsCountLessThan(1) then begin
      LTimedOut := True;
      for i := 1 to (TerminateWaitTime div LSleepTime) do begin
        Sleep(LSleepTime);
        if TIdThreadSafeList(Threads).IsCountLessThan(1) then begin
          LTimedOut := False;
          Break;
        end;
      end;
      if LTimedOut then begin      
        raise EIdTerminateThreadTimeout.Create(RSTerminateThreadTimeout);   // <-- hier
      end;
    end;
  end;
End;//TerminateAllThreads
...
Indy-Version: 9

...die Prozedur TerminateAllThreads in der Unit TIdTCPServer zu der Indy-TCPServer-Komponente dazu gehört? Sorry :(
Deswegen habe ich nicht wirklich Einfluss darauf.


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:04 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz