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

Vaibhav Chauhan

New member
Jan 6, 2013
260
0
0
Visit site
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?
 

BIGPADDY

New member
Sep 30, 2012
10,277
0
0
Visit site
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.
 

Vaibhav Chauhan

New member
Jan 6, 2013
260
0
0
Visit site
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. :)
 

Cheeky Ghosty

New member
Jul 23, 2013
108
0
0
Visit site
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.
 

Jiri Matejka

New member
Aug 29, 2014
28
0
0
Visit site
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
 

Members online

Forum statistics

Threads
323,857
Messages
2,244,525
Members
428,135
Latest member
Maritku