I implemented a windows service that must send a message when the system enters suspend mode. I have set CanHandlePowerEvent and override OnPowerEvent method and I get the power events fine (more or less).
What I have noticed (on my test machine Win8 Pro):
1. OnPowerEvent(PowerBroadcastStatus.QuerySuspend) is NEVER called.
2. OnPowerEvent(PowerBroadcastStatus.Suspend) is called but the OS does not wait for the method to complete, it enters suspend mode regardless. When the method is interupted, it completes after the system resumes operation. There is no way to tell that OnPowerEvent(PowerBroadcastStatus.Suspend) will execute before system enters suspend state or after resume.
Does anyone know how to approach this problem?