Re: SendMessage (in secondary thread) freezes application GUI thre
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Thu, 9 Nov 2006 08:47:02 -0700
It might help to understand how a Win32 application works. Since MFC is
just a class library, it *is* calling GetMessage(). It's just doing it for
you and you aren't coding it explicitly.
Paul T.
"skyapie" <skyapie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CB036DCB-6925-4AA9-B844-ABB35EA0B377@xxxxxxxxxxxxxxxx
Do I need to use GetMessage?
Will ON_MESSAGE(x, y) remove the message from the message queue as well?
"Paul G. Tobey [eMVP]" wrote:
SendMessage blocks until the window that you've sent the message to is
done
processing it (that's why PostMessage exists). I would guess that you
have
a deadlock there.
Thread A calls SendMessage while holding an exclusive lock on something.
This might be a mutex, a spin lock, almost any object designed to prevent
a
second thread from accessing some resource.
Thread B calls GetMessage() and begins processing it, but, because
there's a
lock on the object, it goes into a wait state until the lock is released.
Obviously, the lock is never going to be released, since SendMessage
doesn't
return until the message processing is complete. It's possible that the
'lock' is something which is automatically released by the OS after some
period of time or there might be a long time-out on the wait.
Paul T.
"skyapie" <skyapie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9416563C-37F0-46DC-9515-949477AF299C@xxxxxxxxxxxxxxxx
Asking this question in a simpler way,
What could cause SendMessage to get stuck, causing the receipient hWnd
to
not get it's message?
Thanks
skyapie
"skyapie" wrote:
Hi,
Has anyone ever come across the same problem and found a solution to
the
following?
I have 1 background thread that periodically calls "SendMessage". The
SendMessage sends a message to my main thread (which also handles the
GUI),
saying "start processing!" The main thread then starts processing, and
returns to the secondary thread when it has completed the processing
it
needs
to do and updated the GUI.
This works fine most of the time, but randomly the GUI on my
application
will freeze (I can tell because there's a clock on the screen that
suddenly
just disappears... and this clock changes the time it displays by
doing a
time(¤tTime), and updating the display on every OnDraw function call.
(Received when WM_PAINT gets processed).
The odd thing is, the application un-freeze (come back to life) after
1/2
hour to 1 hour... And all my logging statements always stop at the
same
point
when my application freezes. I log a statement before SendMessage, and
at
the
point where the message handling function gets entered. My log shows
that
the
SendMessage statement gets executed, but the message handling function
in
the
active view doesn't get entered.
Can anyone help please?? I have no clue how to debug into SendMessage,
let
alone reproduce this consistently. The freezing seems to happen
randomly
at
the same point in the code. (IE: it works most of the time.... )
Much appreciated
skyapie
.
- Follow-Ups:
- Re: SendMessage (in secondary thread) freezes application GUI thre
- From: Michael J. Salamone
- Re: SendMessage (in secondary thread) freezes application GUI thre
- References:
- Re: SendMessage (in secondary thread) freezes application GUI thread?
- From: Paul G. Tobey [eMVP]
- Re: SendMessage (in secondary thread) freezes application GUI thre
- From: skyapie
- Re: SendMessage (in secondary thread) freezes application GUI thread?
- Prev by Date: Re: SendMessage (in secondary thread) freezes application GUI thre
- Next by Date: Re: application not starting.
- Previous by thread: Re: SendMessage (in secondary thread) freezes application GUI thre
- Next by thread: Re: SendMessage (in secondary thread) freezes application GUI thre
- Index(es):
Relevant Pages
|
Loading