Indy inside of a manged thread?

Giganews Newsgroups
Subject: Indy inside of a manged thread?
Posted by:  Jeremy Darling (jdarli…@eonclash.com)
Date: Thu, 6 Oct 2005

I'm working on using indy from inside of a managed thread.  The thread
creates an instance of TIdTCPServer and multiple instances of TIdTCPClient
in a P2P fassion for an internal chat type application.  In the threads
destructor I am performing the following:

destructor TCommunicationsThead.Destroy;
begin
  with FClients.LockList do
    begin
      while Count > 0 do
        begin
          TIdTCPClient(Items[0]).Disconnect;
          TIdTCPClient(Items[0]).Free;
          Delete(0);
        end;
    end;
  FServer.Active := false;
  FServer.Free;
  inherited;
end;

The problem is that when I set FServer.Active to false I get an exception in
IdCustomTCPServer.pas at ln 931 on:
        Server.Scheduler.TerminateYarn(LYarn);

Any ideas why this would happen, is it something to do with the fact that
I'm running the server and clients inside a thread that is not the main
application thread?  Since they create their own threads I didn't figure
that this would be the problem.  If I need to post up the entire project I
can as its quite small.

Jeremy

Replies