Setting an alarm in Windows Phone 7

In the Application_Exit application, I am trying to set an alarm using ScheduledActionService. This works fine in other code, but here it continues to throw an argument with the message E_INVALIDARG

Here is the code

 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

Any ideas what I'm doing wrong here?

+2
source share
1 answer

I added this code to the method Application_Closingand it did not throw an error. It seems that it is too late in the Exit event to schedule an alarm.

+3
source

All Articles