Difference between OpenNETCF.WindowsCE.Suspend and OS suspend

460 views Asked by At

For our Windows Mobile solution we are using the OpenNETCF.WindowsCE.Suspend method to suspend the device after a period of time. This is instead of using the OS timeout (HKLM\System\CurrentControlSet\Control\Power\Timeouts\BattSuspendTimeout). The reason for this is if the device is suspended by the OS or the power button is pressed to suspend the device then the device seems to wake up of its own accord however if the OpenNETCF.WindowsCE.Suspend method is used, then the device will remain asleep until the power button is used to wake it.

Would someone be able to confirm, either way, whether an OpenNETCF.WindowsCE.Suspend puts the device in the same state as the device sleeping of its own accord via the BattSuspendTimeout?

1

There are 1 answers

0
josef On

I dont have the source code of OpenNetCF.WindowsCE to say for sure what is the difference. I would look at the code or use my power monitor tool to see which exact Power Mode is entered by OpenNetCF and BattSuspendTimeout. As you know, there are several Power Modes defined: http://msdn.microsoft.com/en-us/library/aa929251.aspx

My power monitor is at https://github.com/hjgode/logging_ce/tree/master/PowerMsgLog.

If ctacke is reading your post, he may say what the exact code is behind OpenNetCF.WindowsCE...

OK, I digged it:

    public static void Suspend()
    {
        if (NativeMethods.SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Suspend, 4096) != 0)
        {
            NativeMethods.GwesPowerOff();
        }
    }

Now we still do not know, which method is used:

SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Suspend, 4096)

or

GwesPowerOff();

Please try my powerMsgLog tool.

I see these difference:

OpenNetCF:

09:40:42 ReadMsgQueue: 
09:40:42 ReadMsgQueue: PBT_POWERINFOCHANGE
09:41:00 ReadMsgQueue: 
09:41:00 ReadMsgQueue: PBT_POWERINFOCHANGE
09:41:12 ReadMsgQueue: PBT_POWERINFOCHANGE
09:41:24 ReadMsgQueue: PBT_POWERINFOCHANGE
09:41:27 ReadMsgQueue: suspend

device is 'off'

09:41:31 ReadMsgQueue: resuming
09:41:32 ReadMsgQueue: 
09:41:32 ReadMsgQueue: on
09:41:43 ReadMsgQueue: PBT_POWERINFOCHANGE

Power button:

09:41:55 ReadMsgQueue: PBT_POWERINFOCHANGE
**09:41:56 ReadMsgQueue: unattended**
09:41:56 ReadMsgQueue: suspend

device is 'off'

09:42:04 ReadMsgQueue: resuming
09:42:06 ReadMsgQueue: 
09:42:06 ReadMsgQueue: on
09:42:07 ReadMsgQueue: on
09:42:16 ReadMsgQueue: 
09:42:16 ReadMsgQueue: PBT_POWERINFOCHANGE