Re: Whats the difference between TIdContext & TIdPeerThread?

Giganews Newsgroups
Subject: Re: Whats the difference between TIdContext & TIdPeerThread?
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Mon, 26 Jun 2006

"Jamie Dale" <j.da…@turboz.net> wrote in message
news:9CA4E558DCFDE240j.da…@turboz.net...

> Can anyone tell me what the difference is now?

As far as your event handler code is concerned, there is very little
difference at all.  Use TIdContext the same way that you used TIdPeerThread.
The differences are internal to Indy, as TIdTCPServer in Indy 10 uses a very
different threading model than Indy 9 did.

> Can I simply swap AThread to AContext in my code?

For most situations, yes.

> If so, how does it affect things like
> TIdPeerThread(AThread).Connection.WriteLn('comment'); ??

Why are you type-casting to begin with?  The event handlers have the AThread
parameter typed as TIdPeerThread, so there is no need to type-cast the
parameter to a type that it already is.  Just use it as-is:

    AThread.Connection.WriteLn('comment');

Which then translates to Indy 10:

    AContext.Connection.IOHandler.WriteLn('comment');

Gambit

Replies

In response to

Whats the difference between TIdContext & TIdPeerThread? posted by Jamie Dale on Mon, 26 Jun 2006