我在我的 WP7 应用程序中添加了计划任务代理来定期提醒。在 2-3 天后进行测试时,代理将关闭,即使我打开应用程序并再次启动任务,它也不会再次返回。以下是我在 ScheduledTaskAgent 中尝试过的内容:
protected override void OnInvoke(ScheduledTask task)
{
DateTime time = DateTime.Now;
if (time.Hour > 6 && time.Hour < 23)
{
getContent();
if (task.Name.Equals("PeriodicTaskDemo", StringComparison.OrdinalIgnoreCase))
{
ShellToast toast = new ShellToast();
Mutex mutex = new Mutex(true, "ScheduledAgentData");
mutex.WaitOne();
IsolatedStorageSettings setting = IsolatedStorageSettings.ApplicationSettings;
toast.Title = setting["ScheduledAgentData"].ToString();
mutex.ReleaseMutex();
toast.Content = "You are being notified!!";
toast.Show();
}
NotifyComplete();
}
}