Search code examples
c#uwpsleepalarm

UWP wake up from hybernation


Currently I have created a uwp C# application which is a basic alarm.

The problem is when the device is placed into sleep mode, no notifications wake up the device.

I am using the following:

var notify = ToastNotificationManager.CreateToastNotifier();
notify.AddToSchedule(myNotification);

myNotification will appear at the right time unless the machine has been turned off, by that I mean sleep mode not actual full power down.

Is there a way to wake the machine from sleep mode just before the notification happens?


Solution

  • In general, there is no API that allows you to wake up the PC from sleep. A good confirmation of this is that even the official Alarms app in many cases displays the following warning:

    Alarms app

    However, this does not hold when the device supports InstantGo, which will wake up on Alarms and timers as long as battery life is not a problem. This feature is supported on many new models of notebooks and tablets. You can see official response on Microsoft Answers:

    If the computer goes to sleep, alarms and timers might not work. Only newer laptops and tablets with a feature called InstantGo can wake up from sleep to sound an alarm or timer. And even with InstantGo, the device might not wake up if it isn’t plugged in.

    Finally, all this holds for Sleep state, but in case of Hybernation, I think the PC will not wake up in any case.