Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Apr : Re: Simple Indy event question

www.cryer.info
Managed Newsgroup Archive

Re: Simple Indy event question

Subject:Re: Simple Indy event question
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Tue, 11 Apr 2006 11:36:00

"IanH" <none@nospam.com> wrote in message
news:443b99ff@newsgroups.borland.com...

> If I create a UDP (or TCP) server in my main program thread,
> and attach an OnUDPRead or similar event, is the event
> automatically processed in the main thread?

The OnUDPRead event specifically is triggered in the context of main thread
by default.  Set the server's ThreadedEvent property to True to trigger the
event in the context of the server's internal worker thread instead.

TCP server events are never triggered in the context of the main thread.
TCP connections are managed by their own threads that are internal to the
server.  The events are always triggered in the context of those threads.

> If I created the server in a separate thread, would the event
> be executed by that thread?

That will never happen.  Again, TCP server events are always triggered in
the context of their own threads, and the OnUDPRead event will always be
triggered in the context of the main thread when the ThreadedEvent property
is False, or its own thread when True.

> My understanding is that in both cases the answer is yes

Your understanding is not correct.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive