BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

atozedsoftware.indy.servers.tcp

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Apr 24, 2007 2:17 pm    Post subject: atozedsoftware.indy.servers.tcp Reply with quote



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





PostPosted: Tue Apr 24, 2007 2:42 pm    Post subject: Re: atozedsoftware.indy.servers.tcp Reply with quote



<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






PostPosted: Tue Apr 24, 2007 4:24 pm    Post subject: Re: atozedsoftware.indy.servers.tcp Reply with quote



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





PostPosted: Tue Apr 24, 2007 9:11 pm    Post subject: Re: atozedsoftware.indy.servers.tcp Reply with quote

<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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.