Repeat a task with time delay in WinJS

667 views Asked by At

I am developing an app in WinJS and I need to periodically run some tasks with a constant and specified delay between each pair of executions.

In particular, I am intending to update the user's position on the map every 30 seconds.

I am not quite sure how to implement the task scheduler in WinJS. I have looked at the background task class, but that doesn't seem to be much help in my case.

1

There are 1 answers

0
Adam Tuliper On BEST ANSWER

If Im reading this correctly and you simply want to do this while the application is running you just need a javascript timer - setTimeout. note that with setTimeout you pass in the function itself without parenthesis, not a string name. Here's an app sample with a timer that updated the UI, although the main important takeaway here is that you need to make sure you call setTimeout again from within your 'update' function. Check out that code here

If you want some sort of background task to do this and generate a separate image (I dont think thats what you ant, but I'll include that since we're talking about tasks and delays)

If you are using Windows 8.1 (which releases soon) you can use the new scheduler class and pause and resume every 30 seconds as shown here

If you are using Windows 8 (and will work on 8.1) you can if I recall correctly setup your scheduled tasks every fifteen minutes and create one shot tasks for each 30 seconds within that time. run background task on timer