How to detect if windows is going to hibernate or suspend?

后端 未结 2 1653
日久生厌
日久生厌 2020-12-31 04:56

I am using

SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(
    SystemEvents_PowerModeChanged
);

to tell when Windows is

2条回答
  •  暖寄归人
    2020-12-31 05:49

    You can't tell the difference between hibernate and suspend.

    A detailed discussion here.

    The takeaway message is that your question presupposes a false dichotomy: It can be hibernate, suspend, or hybrid sleep... and when hybrid sleep transitions from suspend to hibernate user code isn't even running (in fact there may be no code running, the transition happens in case of power loss).

    So when the decision to hybrid sleep occurs, the system doesn't know whether it will resume from suspend or from hibernation, and it can't tell you what it doesn't know.

提交回复
热议问题