We are seeing some occasional data loss with our application on Windows Mobile, and we suspect that some buffered data is not being flushed to disk when the device is suspending. We would like to manually flush data to the disk when the device is about to suspend. On Windows, we do this by catching the WM_POWERBROADCAST message, but this message is not available on Windows Mobile. I found a two-year-old quote on a message board that said:
You need to realize that you are *not* guaranteed that you will be notified of the suspend *before* you wake up again. That is, you might not receive the notification until after the device has been reawakened. Generally, you should not be trying to react to suspend because of this limitation (and the limitation on what you can do in response to the event, anyway).
Is this (still) true for all devices? Is there a way we can do this?
The quote (which sounds really, really familiar) is still true. The only components that are guaranteed to be able to complete their work before suspend are drivers, and they have a significant set of limitations as well.
The general idea behind a suspend is to be transparent to the application, and getting in front of that generally isn’t a good idea.