Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: TidUDPServer question

www.cryer.info
Managed Newsgroup Archive

Re: TidUDPServer question

Subject:Re: TidUDPServer question
Posted by:"Martin James" (mjames_falc..@dial.pipex.com)
Date:Sun, 4 Jun 2006 05:27:30

> >
> You mean I need to rewrite my entire server?
>
> Oh no...
>

Not that much.

Poor solution - add a critical section acquire/release around the public
string/array accesses so that your timer system can work safely.

Better solution - don't use a timer at all.  Wrap your communications, (ie
string etc), in a class and use the PostMessageAPI to send a custom message
containing the instance reference to a form message-handler.  This is not
only safe, but also has no avoidable latency and will have a better
performance than any other secondary-thread>main-thread comms mechanism.

Polling, with timers or any other mechanism, is not necessary for
inter-thread comms and always adds latency and CPU waste.

Rgds,
Martin

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive