0

In my application (C#, .Net CE 3.5, WM 6.5), I have a thread that do sync with a web service. I want thread keep running if device goes to idle mode. So I use some Windows CE API, to run my thread in unattended mode and keep WiFi on during this process. (API from here). This works perfectly and system goes to standby instead suspend and thread run with WiFi is on. But 1 minute after standby, device goes to Suspend mode and execution stops.

Win32.CoreDLL.PowerPolicyNotify(Win32.PPNMessage.PPN_UNATTENDEDMODE, -1);
IntPtr wifiHabdle= Win32.CoreDLL.SetPowerRequirement(wifiDeviceName,  CEDEVICE_POWER_STATE.D1, DevicePowerFlags.POWER_NAME | DevicePowerFlags.POWER_FORCE, IntPtr.Zero, 0);

//Connect to web service and do jobs ...

Win32.CoreDLL.ReleasePowerRequirement(wifiHabdle);
Win32.CoreDLL.PowerPolicyNotify(Win32.PPNMessage.PPN_UNATTENDEDMODE, 0);

When I change power configuration on device and set "Turn off screen if device not used for" to 2 minutes, unattended mode become 2 minutes before going to suspend. (strange relation). How can I force device to remain in Unattended mode
as long as I call PowerPolicyNotify(Win32.PPNMessage.PPN_UNATTENDEDMODE, 0)

Community
  • 1
  • 1
Behnam
  • 15
  • 1
  • 7
  • 2
    AFAIK you need to use SetPowerRequirement also for your application or use SystemIdleTimerReset periodically: http://www.brianpeek.com/category/Windows-Mobile ~ josef – josef Nov 29 '12 at 10:33
  • @josef, that's the correct answer. Put it in as an answer so you can get credit for it. – ctacke Nov 29 '12 at 13:56
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Nov 29 '12 at 20:13

1 Answers1

2

AFAIK you need to use SetPowerRequirement also for your application and/or use SystemIdleTimerReset periodically: http://www.brianpeek.com/category/Windows-Mobile

Although, in the past I did not success with SystemIdleTimerReset and instead changed the timeouts for battery powermanagement to suspend never and control the power requirements directly (request unattended mode).

Greg
  • 23,155
  • 11
  • 57
  • 79
josef
  • 5,951
  • 1
  • 13
  • 24