Search code examples
multithreadingdelphiindythread-priority

How to change Listener Thread Priority


I use the TIdCmdTCPServer component of Indy 10 to realize my client-server application. The problem is that the request from clients can be fairly complicated and that the GUI part of my server application immediately loses responsiveness. From the Indy Documentation, I got that Indy:

Creates and starts listener threads for Bindings using the thread priority tpHighest.

Can I change that behaviour?


Solution

  • As Rob pointed out, don't change the priority of the listener thread, lower the priority of the worker threads instead. It can be accessed in the OnConnect() handler of the TIdCmdTCPServer instance, like so:

    procedure TServerForm.IdCmdTCPServer1Connect(AContext: TIdContext);
    begin
      // sanity checks need to go here
      TIdYarnOfThread(AContext.Yarn).Thread.Priority := tpLower;
    end;