01-26-2011 06:25 PM
I do not see any events that would message an application that the user is about to quit the application. Obviously, if I have a quit button, I can trap that, but other than deactivate event, if the user select the close button when the app is minimized, there is no way to know that is about to close down the application. Yes, application state should be saved when deactived or low memory, but in the case where the application may have an active connection to another app or service, it would be nice to properly cleanup and close those connections. I did not see anything in the QNXApplication class. Wondering if someone has tripped over something like this.
01-26-2011 07:15 PM
Best I can offer is what I wrote about the PlayBook application lifecycle after experimenting with various events.
In short, it looks to me like responding to DEACTIVATE with quick, blocking calls to save critical state, is the best thing you can do for now. There's an EXITING event that doesn't appear useful right now.
If you have active connections that can't be closed with a blocking call (e.g. you're talking to an SMTP server and you'd like to send QUIT and wait for the server to close the connection, to be "clean"), you have no choice but to try to do it asynchronously and hope that things happen quickly enough that you get done before the user manages to swipe up again or click the X widget. And that may not help if the reason you got deactivated was low battery or memory (so subscribe to those events if you care).
If you were planning to save state externally (over the network) I think you would have little choice but to save it locally as a blocking call (to guarantee that it succeeds) followed by starting an attempt to save again remotely, knowing that attempt may be aborted in the middle as the app closes.
A comment on "clean" shutdown... I expect we can count on QNX to clean up much better after our app than most other OSes would be able to. I don't feel uncomfortable with the idea of having lots of open files, sockets, etc when I go down, provided I've flushed whatever I can flush.
01-26-2011 07:21 PM