Waking up device at a specific time

A

Andy Baker

Hello,

I have a VB.NET 2003 compact framework application. The application will be
running all the time on a mobile device, and part of the requirements is for
the device to access the main SQL Server 2000 database during the night to
upload updated data. The device may possibly be in standby mode at this
point, so if it is, I need to wake it up. I have found some C# code that
uses the OpenNETCF RunAppAtTime method to run an application at a specified
time, that I have incorporated into my app, and it does wake up the device
at the time that I want it to. However, there are a few potential problems
that I can see with this approach.
1) I don't want to run an application, my application will be always
running, so all I need to do is wake up the device. (This doesn't seem to
matter).
2) I can only set the wake up time to a specific date and time. I want
it to be every night (or every working night) at the same time. This means
that I need to set the date and time for the next working day after
uploading, or on start of the application if it is being run for the first
time.
Would setting the same reminder more than once cause any problems?
3) I do not know how to cancel a reminder once set. Is there a way to
see what reminders have been set - at the moment I am keeping a registry
entry with the date of the last reminder, and if it has already been set,
don't do it again.
3) It seems like a very complicated method, with a great potential for
mistakes. Is there a better way?
Unfortunately my C# skills are fairly limited, so although I have got
the code to work, I am not sure exactly what it is doing. I am concerned
that it may be causing me problems - I can see the device grinding to a halt
because I have so many threads running setting reminders all over the place.
Any advice would be appreciated.

Andy Baker
 
G

Guest

1) I don't want to run an application, my application will be always
running, so all I need to do is wake up the device. (This doesn't seem to
matter).

You can have it set a named event that your app can wait on instead of
running an actual app.
2) I can only set the wake up time to a specific date and time. I want
it to be every night (or every working night) at the same time. This means
that I need to set the date and time for the next working day after
uploading, or on start of the application if it is being run for the first
time.
Would setting the same reminder more than once cause any problems?

Set it once for the next time it shoudl run. When it fires, set it again
for the next time, etc. etc. I actually created a class that handles all of
this that will be in the next version of the SDF, due out later this month.
Not sure what your schedule is, but that might help.
3) I do not know how to cancel a reminder once set. Is there a way to
see what reminders have been set - at the moment I am keeping a registry
entry with the date of the last reminder, and if it has already been set,
don't do it again.

You can enumerate the notificatiosn with the Notifications namespace.
3) It seems like a very complicated method, with a great potential for
mistakes. Is there a better way?

No, notifications are the only way to gedt the system to wake at a specified
time.
Unfortunately my C# skills are fairly limited, so although I have got
the code to work, I am not sure exactly what it is doing. I am concerned
that it may be causing me problems - I can see the device grinding to a
halt because I have so many threads running setting reminders all over the
place. Any advice would be appreciated.

You shouldn't have threads "setting reminders all over the place." You
should set them as you need them and know what each and every thread in your
process is doing at all times. The entire alarm/notification system in your
app should be a single background thread that you start at app startup and
that never dies. It should have only 1 notification set at any given time.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
 
A

Andy Baker

Hi Chris

Thanks for getting back to me so quickly. The way that you have described is
the way that I want it to work, I was just a bit worried that I have
misunderstood how it is working and would end up with multiple reminders and
threads. If I can use the Notifications namespace to check was it has
already been set, I can ensure that this is not happening. I am using
VS2003, and OpenNetCF 1.4, will the next version of your SDF be VS2005 only?

Thanks,

Andy Baker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top