【问题标题】:How to customize a Periodic Task on Windows Phone?如何在 Windows Phone 上自定义定期任务?
【发布时间】:2014-02-15 00:47:28
【问题描述】:
【问题讨论】:
标签:
windows-phone-7
windows-phone-8
【解决方案2】:
如果你没有在市场上发布代码你可以做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));