G
Guest
Hi All,
I am little confused here, hope you can help me.
While processing WM_POWERBROADCAST
(wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy
operation(30 sec) before system Suspends or hibernates. To
achieve this, in my message handler when processing
PBT_APMQUERYSUSPEND, I create another thread which takes
care of making this lengthy operation, and when its done I
set event to PBT_APMQUERYSUSPEND message processor(while
it is in WaitForSinleObject), that work was finished and
now can allow windows to suspend/hibernate. The problem is
that when processing PBT_APMQUERYSUSPEND while on
WaitForSinleObject, windows doesn't waits for me to return
value and proceeds with suspend/hibernation. The weird
thing I don't understand is that if I call only MessageBox
() in my PBT_APMQUERYSUSPEND handler, the windows waits
until I press OK, even if I do so after 10 minutes.
So I don't understand why, windows doesn't think my thread
is hung when I call MessageBox and does think its hung
when I have WaitForSingleObject.
I even tried putting PeekMessage that removes all the
messages from window queue and call Sleep(100) , to try
tell windows that I am not hung, but it still resumes with
suspend/hibernation.
Another thing is that, documentation says that it will
wait only 20 seconds until "thinking" my thread is hung if
I don't remove WM_POWERBROADCAST from my message queue,
but I do remove it and do WaitForSingleObject, still it
continues with suspend/hibernation.
(The operation that I should do before suspend/hibernate
is vital, so please don't suggest other things instead..)
Hope some one can help me.
Thanks
I am little confused here, hope you can help me.
While processing WM_POWERBROADCAST
(wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy
operation(30 sec) before system Suspends or hibernates. To
achieve this, in my message handler when processing
PBT_APMQUERYSUSPEND, I create another thread which takes
care of making this lengthy operation, and when its done I
set event to PBT_APMQUERYSUSPEND message processor(while
it is in WaitForSinleObject), that work was finished and
now can allow windows to suspend/hibernate. The problem is
that when processing PBT_APMQUERYSUSPEND while on
WaitForSinleObject, windows doesn't waits for me to return
value and proceeds with suspend/hibernation. The weird
thing I don't understand is that if I call only MessageBox
() in my PBT_APMQUERYSUSPEND handler, the windows waits
until I press OK, even if I do so after 10 minutes.
So I don't understand why, windows doesn't think my thread
is hung when I call MessageBox and does think its hung
when I have WaitForSingleObject.
I even tried putting PeekMessage that removes all the
messages from window queue and call Sleep(100) , to try
tell windows that I am not hung, but it still resumes with
suspend/hibernation.
Another thing is that, documentation says that it will
wait only 20 seconds until "thinking" my thread is hung if
I don't remove WM_POWERBROADCAST from my message queue,
but I do remove it and do WaitForSingleObject, still it
continues with suspend/hibernation.
(The operation that I should do before suspend/hibernate
is vital, so please don't suggest other things instead..)
Hope some one can help me.
Thanks