DeveloperLove
DeveloperLove

Reputation: 567

How to customize a Periodic Task on Windows Phone?

I need to use a customized Periodic Task in Windows Phone 8. I have read from the below link that it runs every 30 minutes.

http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202942(v=vs.105).aspx

So, I am looking for an option to customize this time. Say, I want to run the Periodic Task every 15 Seconds or 20 Seconds.

Is this possible?

Upvotes: 3

Views: 1528

Answers (2)

Clinton Ward
Clinton Ward

Reputation: 2511

If you dont release the code on the market you can do this....

DateTime lastrun;
IsolatedStorageSettings.ApplicationSettings.TryGetValue<DateTime>("lastrun", out lastrun);

if (DateTime.Now.Subtract(lastrun).TotalMinutes < 60) // 60 minutes, so run every hour
{
    System.Diagnostics.Debug.WriteLine("Too soon, stopping.");
    NotifyComplete();
    return;
}

//add proper code for removing old value, etc.

IsolatedStorageSettings.ApplicationSettings.Add("lastrun", DateTime.Now); 

// Launch the task in 6 minutes
ScheduledActionService.LaunchForTest("task", TimeSpan.FromMinutes(6));

Upvotes: 1

robertk
robertk

Reputation: 2461

That is not possible. Every 30min is the lowest interval.

Upvotes: 7

Related Questions