Steffei
Steffei

Reputation: 25

make countdown when app is not active windows phone

I want to make a countdown timer (lets say 20 min.) for my windows phone application. But it should still be counting down, even if the application is not active.

For example: user clicks a button, then this button should not be available for 20 min. Even if the app is restarted, the phone is restartet or whatever.

How should i basically approach this? Is the background agent the way to go? Make some kind of periodicall shedule? Or read the phone clock? Or are there other possibilities?

It should also not be easy to avoid (for example change the time on the phone, so that it is 20 min. later on the clock)

Has someone an idea? just searching for a point in the right direction here :). Thanks

Upvotes: 0

Views: 73

Answers (1)

lsuarez
lsuarez

Reputation: 4992

If you don't trust the phone to provide the time of record, the obvious answer is to use a remote time server to mark application activation time according to the remote server. If you also mark the local phone time at activation and calculate the difference between the two, you can use that difference to store what the remote server would (ideally) believe to be the current time that the button is pressed without having to call the remote server again.

One example of such a service is http://www.timeapi.org/utc/now.

Upvotes: 1

Related Questions