Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: Nailed it!

www.cryer.info
Managed Newsgroup Archive

Re: Nailed it!

Subject:Re: Nailed it!
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Tue, 27 Jun 2006 11:06:28

"Martin James" <mjames_falcon@dial.pipex.com> wrote in message
news:44a138bb@newsgroups.borland.com...

> AFAIK, a WMQ cannot be purged except by a GetMessage/PeekMessage
> loop. Since your custom messages in the queue are mixed-in with other OS
> and other custom messages, the loop would have to get/peek messages and
> check each one to see if it is one that should be purged, keeping a count
of
> 'real' custom messages that have been dumped, until th ecount reaches 99.

PeekMessage() has filtering parameters.  You can specify the custom message,
and it will only return those messages and keep the rest in the queue.  If
you use RegisterWindowMessage() to create the custom message, then you are
pretty much guaranteed not to accidently remove wrong messages that may be
using the same numeric value.  And you don't have to stop at 99.  Just keep
looping until all of the custom messages have been purged.  The other
threads are blocked from posting new messages to the queue until the
thread-safe queue is unlocked, so do the purging while the queue is still
locked.

> One window per app?  I think the OS will not miss such a resource.

Even a single window uses up GDI resources that could otherwise be used for
other things.  If a thread is not going to use that window, then there is no
point in tying up those resources.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive