Article View: borland.public.cppbuilder.nativeapi
Article #13906PeekMessage/SendMessage and threads
From: nicolasr
Date: Sun, 07 Sep 2003 22:24
Date: Sun, 07 Sep 2003 22:24
30 lines
1898 bytes
1898 bytes
Hi,
while working with threads I sometimes encountered
deadlocks in the apps shutdown sequence. I had a look at
the VCL TThread WaitFor() method and now have
some questions about SendMessage()/PeekMessage().
TThreads WaitFor() does something similar to this:
while MsgWaitForMultipleObjects(1, ThreadHandle, False, INFINITE,
QS_SENDMESSAGE) = WAIT_OBJECT_0 + 1 do PeekMessage(Msg, 0, 0, 0,
PM_NOREMOVE);
If I understand correctly this code should wait for the thread
but if the thread is blocked waiting for messages to be
handled by the main thread those messages are handled first.
The WinAPI help says something about how a SendMessage()
from a different thread works. What I don't understand, though, is
what the call to PeekMessage() actually does?
Why is PeekMessage() called with PM_NOREMOVE?
Does this call unblock the thread?
Since the message is not actually processed, what about
the return value of SendMessage()?
thanks for any ideas,
Nick
Technical Details
Message-ID:
<3f5bb022@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,d49ccccc71a00b3e,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-07 15:26:07 PST From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net> Newsgroups: borland.public.cppbuilder.nativeapi Subject: PeekMessage/SendMessage and threads Date: Mon, 8 Sep 2003 00:24:32 +0200 Lines: 32 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 80.133.172.114 Message-ID: <3f5bb022@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1062973474 80.133.172.114 (7 Sep 2003 15:24:34 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail