Click here to Skip to main content
6,633,937 members and growing! (17,451 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » General     Intermediate

Suspend Killer for WinCE.NET 4.2

By D. Ajith Nilantha de Silva

WinCE system suspend.
C++, eVC 4.0, Windows, Mobile, Visual Studio, Dev
Posted:31 Mar 2005
Views:46,432
Bookmarked:18 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 3.11 Rating: 4.00 out of 5

1

2
1 vote, 16.7%
3
3 votes, 50.0%
4
2 votes, 33.3%
5

Introduction

Have you tried to keep the device which is running on WinCE.NET without going to suspend while watching video. Here's how to do it without changing the power settings manually.

Background

I was developing a video play back module for WinCE.NET 4.2 and encountered a problem that the system goes to suspend mode according to the settings in the registry while watching a video. First, the backlight goes off and afterwards the system goes to suspend mode. The way normally we do is change the settings in power manager which is not practical every time.

Using the code

I tried to stop it calling SystemIdleTimerReset() but it was unable to stop the device going to suspend sometimes. Because, we have to check the timeout when the power manager event gets fired and call the SystemIdleTimerReset() before it. Calling SystemIdleTimerReset() in a thread or timer works. But we need to consider about the performance since it is a mobile device.

So I tried to do it by firing a key board event to the application message loop. Key board events were generated in a timer process and did it as follows:

//Define the constants to generate key board event

#define VK_NONAME       0xFC
#define KEYEVENTF_KEYUP 0x2


//in the timer process added the following line

keybd_event(VK_NONAME, 0, KEYEVENTF_KEYUP, 0);

It worked fine. Device did not go to suspend mode. But application gets an extra message, and since it is a mobile device, I thought it is better to get rid of this extra process and find a nice solution which does not affect the application performance. Finally, I was able to develop a nice and robust class which does the task I want as it is. So I called it SuspendKiller. SuspendKiller uses the registry, power manager notification call and Backlight power request call to accomplish the task.

Suspend Killer functions in the following sequence:

  1. Loads the settings from the registry and saves those in an array for future reference.
  2. Sets the new settings to Never (0) in the relevant registry keys.
  3. Notifies the Power Manager event to re-load the settings from the registry.
  4. Turn On the backlight with full power.
  5. When the function is called with FALSE parameter, it reveres everything. (Sets the original values, releases the backlight power.)

It does not affect the application performance since we do it once when the media is about to play and stop.

To do this task, I tried many approaches and also tried with interrupts. But I think this solution is nice and clean. Also tested with iMX21 ADS with WinCE.NET 4.2 and worked perfectly while watching a video for more than one hour.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

D. Ajith Nilantha de Silva


Member

Location: United States United States

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 14 of 14 (Total in Forum: 14) (Refresh)FirstPrevNext
GeneralSuperb Pinmemberramesh bs4:40 2 Sep '09  
QuestionHead file "Pm.h", cannot find it PinmemberAnthony S.0:13 14 Jul '06  
AnswerRe: Head file "Pm.h", cannot find it Pinmemberajith0:54 27 Oct '06  
GeneralGuarantee registry restore?? PinmemberLewisw1:30 16 Jun '06  
GeneralRe: Guarantee registry restore?? Pinmemberajith0:42 27 Oct '06  
QuestionGot .Net PinmemberJumba66665:51 24 Mar '06  
AnswerRe: Got .Net Pinmemberajith22:23 18 May '06  
GeneralNot Working in Windows Mobile 5 Pinmembermiggedy9:21 16 Jan '06  
GeneralRe: Not Working in Windows Mobile 5 Pinmembermiggedy9:50 16 Jan '06  
GeneralRe: Not Working in Windows Mobile 5 Pinmemberajith23:35 13 Feb '06  
QuestionRe: Not Working in Windows Mobile 5 Pinmemberroznicki11:07 27 Apr '09  
Generalneed some guidance for power managment in pocket pc Pinsussalokb7:22 29 Aug '05  
GeneralRe: need some guidance for power managment in pocket pc Pinmemberajith23:32 13 Feb '06  
GeneralRe: need some guidance for power managment in pocket pc Pinmemberajith0:01 14 Feb '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 31 Mar 2005
Editor: Smitha Vijayan
Copyright 2005 by D. Ajith Nilantha de Silva
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project