Windows phone 7 在Windows Phone 7中设置报警

Windows phone 7 在Windows Phone 7中设置报警,windows-phone-7,Windows Phone 7,在我的应用程序退出事件中,我试图使用ScheduledActionService设置警报。这在其他代码中可以正常工作,但在这里它不断抛出带有消息E_INVALIDARG的argumentexception 这是密码 string alarmName = Guid.NewGuid().ToString(); const string cookingClockAlarm = "Cooking clock alarm"; DateTime dueTime = DateTime.Now.AddSe

在我的应用程序退出事件中,我试图使用ScheduledActionService设置警报。这在其他代码中可以正常工作,但在这里它不断抛出带有消息E_INVALIDARG的argumentexception

这是密码

 string alarmName = Guid.NewGuid().ToString();
 const string cookingClockAlarm = "Cooking clock alarm";
 DateTime dueTime = DateTime.Now.AddSeconds(10);
 var alarm = new Alarm(alarmName)
                    {
                        Content = cookingClockAlarm,
                        BeginTime = dueTime,
                        ExpirationTime = dueTime.AddSeconds(3),
                        RecurrenceType = RecurrenceInterval.None
                    };
 // Register the alarm with the system.
 ScheduledActionService.Add(alarm);//here I get an exception

你知道我做错了什么吗?

我在
应用程序关闭
方法中添加了这段代码,它没有抛出错误。在退出事件中,安排报警似乎为时已晚。

有趣的是,我对ScheduledActionService的调用也遇到了同样的问题。发现这是在应用程序关闭时发生的。