我沒有OpenNetCF.WindowsCE的源代碼來說肯定有什麼區別。我會查看代碼或使用我的電源監視器工具查看OpenNetCF和BattSuspendTimeout輸入的確切電源模式。如您所知,定義了幾種電源模式:http://msdn.microsoft.com/en-us/library/aa929251.aspx
我的電源監視器位於https://github.com/hjgode/logging_ce/tree/master/PowerMsgLog。
如果ctacke正在讀您的文章,他可能會說確切的代碼背後是什麼OpenNetCF.WindowsCE ...
OK,我挖吧:
public static void Suspend()
{
if (NativeMethods.SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Suspend, 4096) != 0)
{
NativeMethods.GwesPowerOff();
}
}
現在我們仍然不知道,該方法用於:
SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Suspend, 4096)
或
GwesPowerOff();
請試試我的powerMsgLog工具。
我看到這些差異:
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
設備是 '關閉'
09:41:31 ReadMsgQueue: resuming
09:41:32 ReadMsgQueue:
09:41:32 ReadMsgQueue: on
09:41:43 ReadMsgQueue: PBT_POWERINFOCHANGE
電源按鈕:
09:41:55 ReadMsgQueue: PBT_POWERINFOCHANGE
**09:41:56 ReadMsgQueue: unattended**
09:41:56 ReadMsgQueue: suspend
設備是 '關閉'
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