Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Aug : Re: TIdTCPServer and Synchronize when moving from Indy 9 to Indy 10
| Subject: | Re: TIdTCPServer and Synchronize when moving from Indy 9 to Indy 10 |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Thu, 17 Aug 2006 15:32:44 |
"Bruce" <exnihilosys_nospam_@hotmail.com> wrote in message
news:44e4dc61$1@newsgroups.borland.com...
> In the execute method of the server component I used to use
> the AThread. parameter to syncronize with the UI:
>
> AThread.Synchronize(ShowTheMessageWindow);
>
> How do I do this with Indy 10's version of the TIdTCPServer?
Use the TIdSync class, ie:
uses
IdSync;
TIdSync.SynchronizeMethod(ShowTheMessageWindow);
TIdSync is also available in Indy 9, so you can write code to cater for both
versions, if you wish, ie:
uses
IdSync;
type
TMySync = class(TIdSync)
{$IFNDEF INDY100}
pubilc
class procedure SynchronizeMethod(AMethod: TIdThreadMethod);
{$ENDIF}
end;
{$IFNDEF INDY100}
class procedure TMySync.SynchronizeMethod(AMethod: TIdThreadMethod);
begin
with Create do try
Thread.Synchronize(AMethod);
finally Free; end;
end;
{$ENDIF}
{$IFDEF INDY100}
procedure TMyForm.IdTCPServer1Execute(AContext: TIdContext);
{$ELSE}
procedure TMyForm.IdTCPServer1Execute(AThread: TIdPeerThread);
{$ENDIF}
begin
TMySync.SynchronizeMethod(ShowTheMessageWindow);
end;
> How do I access the thread the server is running under so
> I can access the Synchronize?
You don't.
Gambit