Mango From Scratch
One of the very cool features coming in Mango is Reminders, and more generally, scheduled tasks. This allows you to set up a reminder and then exit the application. When your reminder fires you have the opportunity to snooze the reminder or to enter the application. And if you enter the application you can enter not only at the home page, but also deep within the application at the relevant page for the reminder.
To get started, let’s strip down an example shown at Mix 11 by Peter Torr to its absolute essence. We’ll create a new Mango application and place a button which says “Remind Me” on the main page. In the code behind, the click event handler for the button creates the Reminder (and passes in a name so that we can, if we choose, refer to the reminder programmatically).
We then set the title of the reminder, the amount of time to wait for it to show itself (BeginTime) and a Uri for where to return to should the user click on the reminder. Finally, we register the reminder with the ScheduledActionService which will manage all the reminders and alarms. Here’s the code for the click event handler,
void Reminder_Click( object sender, RoutedEventArgs e ) { Reminder r = new Reminder( "Dinner" ); r.Title = "Dinner"; r.Content = "Time to eat dinner"; r.BeginTime = DateTime.Now.AddSeconds( 10 ); r.NavigationUri = NavigationService.CurrentSource; ScheduledActionService.Add( r ); }
To test the application click the button and then exit the application. About 10 seconds later the reminder will pop up and clicking on it will return you to the original page.
4 Responses to What’s Coming In Mango–Reminders