| View previous topic :: View next topic |
| Author |
Message |
Bruce Guest
|
Posted: Fri Aug 18, 2006 2:15 am Post subject: TIdTCPServer and Synchronize when moving from Indy 9 to Indy |
|
|
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? How do I access
the thread the server is running under so I can access the Synchronize?
Thanks, Bruce |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Aug 18, 2006 3:32 am Post subject: Re: TIdTCPServer and Synchronize when moving from Indy 9 to |
|
|
"Bruce" <exnihilosys_nospam_ (AT) hotmail (DOT) com> wrote in message
news:44e4dc61$1 (AT) newsgroups (DOT) borland.com...
| Quote: | 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;
| Quote: | How do I access the thread the server is running under so
I can access the Synchronize?
|
You don't.
Gambit |
|
| Back to top |
|
 |
Bruce Guest
|
Posted: Fri Aug 18, 2006 4:02 am Post subject: Re: TIdTCPServer and Synchronize when moving from Indy 9 to |
|
|
Thanks. How does TIdSync.SynchronizeMethod know which thread the
TIdTCPServer is running under? Do I need to link the components somehow?
Bruce
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:44e4eece$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Use the TIdSync class, ie:
uses
IdSync;
TIdSync.SynchronizeMethod(ShowTheMessageWindow);
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Aug 18, 2006 8:11 am Post subject: Re: TIdTCPServer and Synchronize when moving from Indy 9 to |
|
|
"Bruce" <exnihilosys_nospam_ (AT) hotmail (DOT) com> wrote in message
news:44e4f578$1 (AT) newsgroups (DOT) borland.com...
| Quote: | How does TIdSync.SynchronizeMethod know which thread
the TIdTCPServer is running under?
|
It doesn't. Unless explicitally passed as a constructor parameter, TIdSync
will create its own helper thread internally and then calls Synchronize() on
that.
Gambit |
|
| Back to top |
|
 |
|