Reputation: 1311
I need to detect power state changes in Modern Standby. In my specific use case, I'm trying to detect (and react) to S0 low-power (sleep) on a Microsoft Surface Pro.
So far, I have tried these methods from a plain Console Application (VS 2019):
SystemEvents.PowerModeChanged.
While I can get these to work well with my laptop, I cannot seem to capture the S0 low-power event, which the Surface Pro uses, with any of these classes.
If you follow the link for the ManagementEventWatcher, I have tried that exact code, but do not even get the "EventArrived" when invoking sleep on the Surface Pro.
Any thoughts and/or pointers?
EDIT: I guess somewhere in WMI it is possible to detect the S0 state. Perhaps some experts in WMI knows? E.g. what classname and scope to use with ManagementEventWatcher...
Upvotes: 3
Views: 868
Reputation: 1
start from windows 8, there is a PowerRegisterSuspendResumeNotification() API, although it's c++, guess there should be some similar api in c#
Upvotes: -1