Click here to Skip to main content
15,902,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I developed a Windows mobile application using C#. I want when I install my application on mobile to prevent this mobile from going to sleep mode, I found that SystemIdleTimerReset() function does that. BUT I don't know where to put and how to let it be called every 30 seconds ???
Posted
Updated 6-Mar-10 22:55pm
v2

and the most important thing... will it work if I press sleep mode button?

Sorry for the delay, I only got notified when you changed my answer:

Not that familiar with CE3, but it should just be a case of:

    Timer tim = new Timer();
    tim.Interval = 30000;
    tim.Tick += new EventHandler(tim_Tick);
    }
void tim_Tick(object sender, EventArgs e)
    {
    SystemIdleTimerReset();
    }
As for your sleep button, On sleep disable the timer, on wakeup restart it.
 
Share this answer
 
v3
SystemIdleTimerReset is there to prevent the mobile device from going into sleep mode to preserve the battery power. If you continually call it, the battery is going to go flat quite quickly. If you must do this, set up a Timer with a thirty second interval, and call SystemIdleTimerReset from that. As a user though, I would get extremely fed up if an app ignored my power-down settings and flattened my battery!
 
Share this answer
 
v2
Thank you for your answer, i found a solution & it workes for me when it goes to sleep automatically, but the problme that it doesnt work when i click on sleep mode button. i dont want my device to go to sleep mode never since my application is running .
 
Share this answer
 
Yeah, I know all that you said. My problem is that I don't know how to apply it on my code ..
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900