Power Advice

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

I'm having a little trouble with power management and wondered if
anybody on the group has any suggestions.

I have an application which manipulates an XML file. This application
automatically saves the modified data every 5 minutes while the user is
using the program, just encase the unit is dropped :-) The other thing I
have decided to do is also save the file before the unit goes into
suspend mode. I have code which detects a change in the power status in
a separate thread. When the POWER_STATE_SUSPEND signal is detected I
make a call

MainForm.Invoke(new EventHandler(MainForm.mnu_SaveData));

But when I pull the memory card out, without switching the unit on, and
check it in the PC the data file has not been updated.

Can anybody point me in the direction of how standby works or what order
things happen in i.e. Storage Cards power down, Applications get the
standby call, etc. as this is driving me mad!!

Thanks for any information

Ryan
 
You're not getting the notification before you go to sleep. When the device
goes to sleep, the power manager puts the power state change into the power
notification queue, and then continues with its work to shut down the
device. This happens quite quickly. An application listening to the queue
*might* get notified that the power is going away, but you certainly won't
have enough time to do any meaningful work. Plus the file system and SD
slot drivers will also be shutting down, so they're likely not going to be
available for you to do writes anyway. When you power back up, your
application is likely completing it's action and saving then.

There is no way for a driver to insert itself into the power down sequence -
only drivers can do that. And even they cannot call any APIs during that
time - it's strictly meant to allow them to turn off hardware and clean up.
 
Back
Top