Reputation: 15
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)
Upvotes: 0
Views: 1097
Reputation: 5959
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).
Upvotes: 2