Can i update DateTime as long as my app is running?

Vaibhav Chauhan

New member
Jan 6, 2013
260
0
0
Suppose i wish to create a night clock app, it will use DateTime, and since the app shall remain open, i can update the DateTime every minute right?
What is the ideal way to do that? Use a loop?(which i doubt)
A background agent?
How fast a background agent can update if the app is running?
 
I should use a loop, but that might not be the best way to do it. I'm only a basic developer :wink:
 
Loops don;t update the DateTime, i used DisptachTimer.
Works well.
Your apps in store?

Ok, sorry about that, I didn't know :wink: No, I don't have any app in the store because I'm only 17 so I can't get a dev account :unhappy:
 
Ah another year to go, keep developing! ;)

Yea, I am. I just got a new pc, so I'm thinking about starting a project so I have something ready to publish when I get 18. The problem is that I can't come up with any good idea. :unhappy:
 
Suppose i wish to create a night clock app, it will use DateTime, and since the app shall remain open, i can update the DateTime every minute right?
What is the ideal way to do that? Use a loop?(which i doubt)
A background agent?
How fast a background agent can update if the app is running?

Use a background agent and I think the max for updating is about every 5 seconds.
 
Yea, I am. I just got a new pc, so I'm thinking about starting a project so I have something ready to publish when I get 18. The problem is that I can't come up with any good idea. :unhappy:
Don't think too much, just start with normal and simple apps at first, like in my description, make a flashlight app, some apps to pin shortcut tiles, there are plenty of these in the store but they make you base very very strong and i think everyone should start simple, ideas will just come along. :)
 
Use a background agent and I think the max for updating is about every 5 seconds.

Overkill as the OP just wants to see the updating of the Clock within the app. DispatchTimer sounds the goods, probably firing at about a 500 millisecond interval if you want close to second accuracy. just remember that DispatchTimer invokes on the UI thread so the smaller your interval the less likely your UI will respond to touch events etc.
 
BackgroundAgent is not guaranteed to run your task at all. Usually it runs the app (the task resp.) every 30 mins but it depends on battery status, other tasks running etc.

For your case I would use Timer as suggested above, but remember typically the phone is automatically switched off after some timeout to save the battery. You will need to store the transient state to system dictionary and load it again once the app is activated (started again).

Jiri