Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Jan : Re: AThreads and Thread manager..
| Subject: | Re: AThreads and Thread manager.. |
| Posted by: | "Turboz" (turb..@turboz.moved.in) |
| Date: | Sun, 7 Jan 2007 12:38:36 |
Righty, I think I've now got it clear in my head how this all works now but
could you please comment Remy? (Sorry I don't mean to continually be a pain
but I really want to get this all 100% clear in my head before I continue).
For I to Length(Users) -1 do
Begin
If Users[I].Connection.Thread = AThread then
//.Connection being a TConnection object I declared to store IP, AThread etc
You said that was a bad idea. I think I now see why- I was looping through
the array (using resources) to find the appropriate user and match via the
TIdPeerThread itself.
Also, you said the AThread could be dynamically reassigned at any time but
that when the client disconnected, the .Data must be cleared/set to nil;
I didn't mention that when the client disconnected, I was also clearing
their .Thread property in their record within the array. Would that make a
difference to my original method of comparing?
Now, if I understand this correctly, the AThread.Data can simply contain a
pointer of some sort directly to that user in the array - EG the Data could
be an integer of the users index within the array - right???
> //Isn't this the same as what I was trying to do? (Next line below)
>> Client.Thread := AThread;
So, if I have this right, You are assigning the AThread to the Client.Thread
property purely for use for writing messages back out to the client? - EG
Client.Thread.Connection.WriteLn(); ?? - thus making it easier by avoiding
using the other data source (EG my array)
>
> 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!
>
Think I'm getting clearer on this topic, but I'd really appreciate your
thoughts and comments!
Thanks!
none