TIdSchedulerOfThreadPool Access Violation (Indy10 + Supercore)

Giganews Newsgroups
Subject: TIdSchedulerOfThreadPool Access Violation (Indy10 + Supercore)
Posted by:  dumb (sitemast…@NOSPAMgmx.li)
Date: Tue, 26 Apr 2005

The following example cause the AV. Drop TIdCmdTCPServer at form, link with
TIdSchedulerOfThreadPool (PoolSize := 5), start server, stop server, you get
AV. Tracking it down goes to

procedure TIdSchedulerOfThreadPool.TerminateAllYarns;
begin
  // inherited will kill off ActiveYarns
  inherited;
  // ThreadPool is nil if never Initted
  if FThreadPool <> nil then begin
    // Now we have to kill off the pooled threads
    with FThreadPool.LockList do try
      while Count > 0 do begin
        with TIdThreadWithTask(Items[0]) do begin
          Terminate;
          Resume;
          WaitFor;
          Free;
        end;
        Delete(0);
      end;
    finally FThreadPool.UnlockList; end;
  end;
end;

It successfully kills 4 threads, then 5th thread causes the AV.

Thanks.

Replies