.NET Xpress

Microsoft Technology Xplicit

Prevent Idle State

Posted by anandkumar2004 on May 6, 2009

Recently a mobile developer posted me a query how to prevent system idle time?  Indeed in some scenario you must consider this lets say stops the device from sleeping when its playing a video without manually adjust the power setting because most of the end users do not understand properly the power saver concept in win CE   . The point to be notice is  idle time is  60 seconds that means we need to awake the processer before elapse of 60 seconds .Here is the sample code  to Implement this I am using the PowerManagement class of OpenNETCF library

using System;
using OpenNETCF.WindowsCE;

public class SampleClass
{
//Timer thread
private static System.Threading.Timer preventIdleThread;

public SampleClass()
{
//call the delegate elapse of 59 seconds
preventIdleThread = new System.Threading.Timer(new TimerCallback(Reactivate),
null, 0, 59 * 1000);
}

private static void Reactivate()
{
//Powermanagement class of OpenNetCF
PowerManagement.ResetSystemIdleTimer();

}
}

HTH

Cheers
Anand

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>