I've made my investigation in the msdn documentation and i'm pretty sure that the handler you're using is wating for the message
WM_POWERBROADCAST with reason PBT_APMRESUMESUSPEND
BUT PBT_APMRESUMESUSPEND is fired only when triggered by an input (mouse,key,etc)
MSDN ->
WM_POWERBROADCAST Message (Windows)
Here are the messages that centrafuse receives when suspending:
WM_POWERBROADCAST dwPowerEvent:PBT_APMQUERYSUSPEND dwData:00000001
WM_POWERBROADCAST dwPowerEvent:PBT_APMSUSPEND dwData:00000000
When resuming, centrafuse first receives this message :
WM_POWERBROADCAST dwPowerEvent:PBT_APMRESUMEAUTOMATIC dwData:00000000
Centrafuse is still frozen...
Then, the following message is received by centrafuse when i move my mouse or press a key, and then centrafuse wakes up.
WM_POWERBROADCAST dwPowerEvent:PBT_APMRESUMESUSPEND dwData:00000000
I think you could just forget the
PowerModeChangedEventHandler of .Net and just track the WIN32 messages above in your WinProc function.
I mean :
PBT_APMSUSPEND => suspend
PBT_APMRESUMEAUTOMATIC => resume
PBT_APMRESUMESUSPEND => forget
What do you think ?