Reputation: 2987
In my application Application_Exit event i am trying to set an alarm using the ScheduledActionService. This works fine in other code but here it keeps throwing an argumentexception with message E_INVALIDARG
Here's 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 am doing wrong here?
Upvotes: 2
Views: 452
Reputation: 12346
I added this code in the Application_Closing
method and it didn't throw an error. Seems like in the Exit event it is too late to do schedule an alarm.
Upvotes: 3