Reputation: 567
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
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