| View previous topic :: View next topic |
| Author |
Message |
Jorge Woo Guest
|
Posted: Fri Nov 19, 2004 9:37 am Post subject: Can anyone give a examples to use TIdSync in TidTCPServer`s |
|
|
i do not know how to use it.
I should to operate GUI in the Execute Event.
BTW: if i use the TidTCPServer as Server and TTCPClient as Client,
dose I should set the TTCPClient`s ClientType 'ctBlocking'?
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Nov 19, 2004 10:03 am Post subject: Re: Can anyone give a examples to use TIdSync in TidTCPServe |
|
|
"Jorge Woo" <hugeant (AT) 126 (DOT) com> wrote
| Quote: | i do not know how to use it.
I should to operate GUI in the Execute Event.
|
TMySync = class(TIdSync)
protected
procedure DoSynchronize; override;
public
constructor Create(AThread: TIdPeerThread); override;
end;
procedure TMySync.DoSynchronize;
begin
// do whatever you need to do with the GUI...
end;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
//...
with TMySync.Create(AThread) do try
Synchronize;
finally
Free;
end;
//...
end;
| Quote: | BTW: if i use the TidTCPServer as Server and TTCPClient
as Client, dose I should set the TTCPClient`s ClientType
'ctBlocking'?
|
Makes no difference at all. That only effects the client's own reading and
writing. Doesn't have any effect on the server at all.
Gambit
|
|
| Back to top |
|
 |
Jorge Woo Guest
|
Posted: Fri Nov 19, 2004 10:20 am Post subject: Re: Can anyone give a examples to use TIdSync in TidTCPServe |
|
|
Thanks for your advice!
another question:
if i should read&Write the main form`s variable,not do
the GUI operate,do i need to use the TIdSync??
There is only one connection to the TidTCPServer.
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> 写入消息新闻:419dc492$2 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Jorge Woo" <hugeant (AT) 126 (DOT) com> wrote in message
news:419dbecc (AT) newsgroups (DOT) borland.com...
i do not know how to use it.
I should to operate GUI in the Execute Event.
TMySync = class(TIdSync)
protected
procedure DoSynchronize; override;
public
constructor Create(AThread: TIdPeerThread); override;
end;
procedure TMySync.DoSynchronize;
begin
// do whatever you need to do with the GUI...
end;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
//...
with TMySync.Create(AThread) do try
Synchronize;
finally
Free;
end;
//...
end;
BTW: if i use the TidTCPServer as Server and TTCPClient
as Client, dose I should set the TTCPClient`s ClientType
'ctBlocking'?
Makes no difference at all. That only effects the client's own reading
and
writing. Doesn't have any effect on the server at all.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Nov 19, 2004 6:36 pm Post subject: Re: Can anyone give a examples to use TIdSync in TidTCPServe |
|
|
"Jorge Woo" <hugeant (AT) 126 (DOT) com> wrote
| Quote: | if i should read&Write the main form`s variable,not do
the GUI operate,do i need to use the TIdSync??
|
It depends on how the rest of your code is using that variable. Please show
an example.
| Quote: | There is only one connection to the TidTCPServer.
|
It does not matter if you have 1 connection or 1000. You still must
synchronize access to the GUI.
Gambit
|
|
| Back to top |
|
 |
|