views:

214

answers:

1

Hi there,

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

A: 

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

Matt
Yes that is correct, however I need to be able to execute that command when the program has been exited. At the moment I can only do that when the user quits from inside the application not when windows mobile does it for me
jumpingmattflash
Are you talking about windows asking your app to close nicely or when the process is terminated? Also are you using compact framework or is your app a native app? For when windows asks your app to shutdown nicely you can catch that and still remove the scheduled event. One alternative would be to not remove the scheduled event, but have the app that is run check to see if the process is running first, and if it isnt then do nothing and don't schedule a new event.
Matt