Or do I have to pinvoke native code?
I don't want the power status...well I do, but I don't want to poll it all the time and would rather have an event fire.
相关问题
- How to determine file version of dll file in Compa
- What's the best way to create a Windows Mobile
- How can I open an image and edit the image with C#
- How can I make the AssemblyInfo version of a C# .N
- Determine number of GDI handles and USER objects
相关文章
- Is there an event in compact framework that fires
- Upload file to server in Windows mobile C# project
- Get return value from pressed button
- How to format a number with thousands separator in
- GPS in windows mobile
- Windows Mobile Synchronization Error
- “Invalid field in source data: 0” error with Proto
- Generics where T is class implementing interface
No there is not. Generally an application is completely unaware of the power state. When the device suspends, code simply stops executing. When you resume, it starts again at the exact spot it left off.
You can hook into the power management system to get notifications, though be aware that you don't have time to actually react, so it's likely that your code can't actually handle the "going to sleep" event until after it wakes again.
Both These state transitions are exposed in managed functions in the Smart Device Framework's OpenNETCF.WindowsCE.PowerManager class.
If you absolutly need to know when a device is suspending the best alternative available is to run your program in unattended mode. Instead of suspending your device will change to the unattended power state. That is your warning that the device wants to suspend. Do what ever work you needed to do before the device suspends then release your unattended request (note, if other programs are requesting unattended mode to then the device may not ever suspend!).
For more information on unattended mode see http://www.codeproject.com/KB/mobile/WiMoPower1.aspx
For an example of getting power change notifications see http://www.codeproject.com/KB/mobile/WiMoQueue.aspx