Running a scheduled app in unattended mode

This question came up in a webcast:

"I have an app that wakes up the device periodically.  I don't want to waste battery power, so when my app is done doing its thing, I don't want to wait for the normal three minute timeout.  I'd like the device to go to sleep right away if it can.  How do I do this?"

The answer is to put your app into "unattended mode".  You do this by calling PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE).  Then when your app is done doing what it needs to do, call PowerPolicyNotify(PPN_UNATTENDEDMODE, FALSE). 

Note:

This is a reference-counted API, so be careful to pair up each TRUE call with exactly one FALSE call.

The screen will not turn on while you are in unattended mode, which is usually what you want.

PowerPolicyNotify() is defined in pmpolicy.h