R – Windows Mobile 5 – Handle Application Exit

exitprocesswindows-mobile

I'm developing for Windows Mobile 5.0 and have come across a little issue with my app. I'm using the win32 api to schedule a process to run periodically. This is thanks to the code posted at http://www.codeproject.com/KB/mobile/WiMoPower1.aspx (call to CeRunAppAtTime)

The problem I've got however is that if I'm scheduling a process to run and the application is forced closed (say by process exit or turning the phone off) the scheduled item still runs.

Is there a way to handle to process exit so that I can remove my scheduled item? I'm none to familiar with the windows API so any help you can give in managed code will be very much appreciated.

Thanks,
Matt

Best Answer

According to the docs, if you call CeRunAppAtTime with a null time parameter it will remove the existing scheduled run request.