| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Tue Apr 24, 2007 2:17 pm Post subject: atozedsoftware.indy.servers.tcp |
|
|
Hello,
Is it good manner to synchronize TidTCPServer OnConnect, onDisconnect and
OnExecute events using critical section as following:
procedure Tinterf_TCP.AserverSocketConnect(AContext: TIdContext);
begin
..........
try
EntercriticalSection(cs);
Do some job in main thread
finally
LeaveCriticalSection(cs);
end;
end;
procedure Tinterf_TCP.AserverSocketDisconnect(AContext: TIdContext);
begin
..........
try
EntercriticalSection(cs);
Do some job in main thread
finally
LeaveCriticalSection(cs);
end;
end;
procedure Tinterf_TCP.AserverSocketExecute(AContext: TIdContext);
begin
..........
try
EntercriticalSection(cs);
Do some job in main thread
finally
LeaveCriticalSection(cs);
end;
end; |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 24, 2007 2:42 pm Post subject: Re: atozedsoftware.indy.servers.tcp |
|
|
<column (AT) takas (DOT) lt> wrote in message
news:462dcb2f$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Is it good manner to synchronize TidTCPServer OnConnect,
onDisconnect and OnExecute events using critical section as
following: |
No, because using a critical section like that is not enough to ensure
thread safety with the main thread, especially if UI components are
involved.
Use the TIdSync class instead.
Gambit |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Apr 24, 2007 4:24 pm Post subject: Re: atozedsoftware.indy.servers.tcp |
|
|
| Quote: | No, because using a critical section like that is not enough to ensure
thread safety with the main thread, especially if UI components are
involved.
|
What is UI component?
| Quote: | Use the TIdSync class instead.
|
I have no experience with this class. How to use it in my case? For example
I would like to log events:
procedure Tinterf_TCP.Logit(info:string);
begin
..........
end;
procedure Tinterf_TCP.AserverSocketConnect(AContext: TIdContext);
begin
..........
Logit('connect')
end; |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 24, 2007 9:11 pm Post subject: Re: atozedsoftware.indy.servers.tcp |
|
|
<column.column (AT) gmail (DOT) com> wrote in message
news:462de8f0 (AT) newsgroups (DOT) borland.com...
| Quote: | What is UI component?
|
UI = user interface. I was referring to any visual component.
| Quote: | I have no experience with this class.
|
Have you looked at the Indy documentation yet? Also, go to
http://www.deja.com and search through the newsgroup archives, as
examples have been posted many times before.
| Quote: | How to use it in my case? For example I would like to log events:
|
I have posted logging examples many times before.
Gambit |
|
| Back to top |
|
 |
|