Re: SendMessage (in secondary thread) freezes application GUI thre
- From: skyapie <skyapie@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 8 Nov 2006 18:53:01 -0800
Hi Paul,
Thanks for the reply, but I can't see how that could happen in my
application...
Thread A sends the message, and Thread B receives it via:
ON_MESSAGE(THE_MESSAGE, theFunctionThatProcessesTheMessage)
I have a logging statement just before sending the message in thread A, and
another logging statment at the very start of
"theFunctionThatProcessesTheMessage". This log statement never gets logged
(when the freeze happens)... which is why I realised thread B was not even
starting to process the message.
The next point is... I've replaced SendMessage with PostMessage and
SendNotifyMessage, but everything's identical... the application will work
for awhile... and randomly freeze for 1/2 hr to 1 hr...
I can see that there's a resource lock somewhere, could you give me some
recommendations on how to go about debugging this?
(Could the resource lock be on an mfc component somewhere? which is why my
GUI is freezing?)
thanks,
skyapie
"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: Paul G. Tobey [eMVP]
- 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 thread?
- Prev by Date: Re: SBC & Windows CE: Can't get no satisfaction
- Next by Date: Re: SendMessage (in secondary thread) freezes application GUI thre
- Previous by thread: Re: SendMessage (in secondary thread) freezes application GUI thread?
- Next by thread: Re: SendMessage (in secondary thread) freezes application GUI thre
- Index(es):
Relevant Pages
|