Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Jan : Re: AThreads and Thread manager..

www.cryer.info
Managed Newsgroup Archive

Re: AThreads and Thread manager..

Subject:Re: AThreads and Thread manager..
Posted by:"Turboz" (turb..@turboz.moved.in)
Date:Sat, 6 Jan 2007 18:25:49

Hi Remy, sorry to be a pain  but after printing the sample code in this
message, soemthing suddenly stood out at me!

>    procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
>    var
>        //...
>        List: TList;
>        Client, User: TUser;
>        I: Integer;
>    begin
>        // gather information from connecting client ...
>
>        Client := nil;
>        List := Users.LockList;
>        try
>            // check if an existing user is reconnecting...
>            for I := 0 to List.Count-1 do
>            begin
>                User := TUser(List[I]);
>                if (User matches the connecting client) then
>                begin
>                    Client := User;
>                    Break;
>                end;
>            end;
>
>            // check if new user is connecting for the first time...
>            if Client = nil then
>            begin
>                Client := TUser.Create;
>                try
>                    List.Add(Client);
>                except
>                    Client.Free;
>                    raise;
>                end;
>            end;
>
>            // update Client info as needed ...
>            AThread.Data := Client;

//Isn't this the same as what I was trying to do? (Next line below)
>            Client.Thread := AThread;

Seems like you are setting a Client.Thread to the AThread - which is what I
was doing with my array of users! Now I'm slipping back into confusion
territory - Please could you explain?

Many thanks!

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive