Your application can restore a computer that is in a sleep state to the working state by using a
scheduled timer or a device event. This is known as a wake-up event. Use a
waitable timer object to specify the time at which the system
should wake. To create the object, use the
CreateWaitableTimer function. To set the timer,
use the SetWaitableTimer function. The
pDueTime parameter specifies when the timer will be signaled. To specify that the system
should wake when the timer is signaled, set the fResume parameter to
TRUE.
When the system wakes automatically because of an event (other than power switch or user activity), the system
automatically sets an unattended idle timer to at least 2 minutes. This timer gives applications sufficient time
to call the SetThreadExecutionState function
to indicate that they are busy. This time enables the system to return to the sleep state quickly after the
computer is no longer required. The following criteria determine whether the system returns to the sleep
state:
- If the system wakes automatically (that is, no user activity is present), it shuts down as soon as the
unattended idle timer expires, assuming that no applications have called SetThreadExecutionState to indicate that the system is required.
- If the system wakes automatically, but the user provides new input while the event is handled, the system
does not automatically return to sleep based on the unattended idle timer. Instead, the system returns to sleep based
on the system idle timer.
- If the system wakes due to user activity, the system does not automatically return to sleep based on the
unattended idle timer. Instead the system returns to sleep based on the system idle timer.
When the system wakes automatically, it broadcasts the
PBT_APMRESUMEAUTOMATIC event to all
applications. Because the user is not present, most applications should do nothing. Event-handling applications,
such as fax servers, should handle their events. To determine whether the system is in this state, call the
IsSystemResumeAutomatic function. When the
system wakes automatically, the display is not automatically turned on.
If the system wakes due to user activity, the system will first broadcast the
PBT_APMRESUMEAUTOMATIC event followed by a
PBT_APMRESUMESUSPEND event. In addition, the
system will turn on the display. Your application should reopen files that it closed when the system entered sleep and prepare for user input.
Windows Server 2003 and Windows XP/2000: If an application called
SetSystemPowerState with
fForce set to TRUE or the system performed a critical
suspend, the system will broadcast a
PBT_APMRESUMECRITICAL event after
waking.
See Also
- About Power Management
- System Sleep Criteria
Send comments about this topic to Microsoft
Build date: 10/8/2009