/// <summary>
 /// Update the scenario UI.
 /// </summary>
 private async void UpdateUI()
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () =>
     {
         Progress.Text = BackgroundTaskSample.ServicingCompleteTaskProgress;
         Status.Text   = BackgroundTaskSample.GetBackgroundTaskStatus(BackgroundTaskSample.ServicingCompleteTaskName);
     });
 }
        /// <summary>
        /// Register a ServicingCompleteTask.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RegisterBackgroundTask(object sender, RoutedEventArgs e)
        {
            var task = BackgroundTaskSample.RegisterBackgroundTask(BackgroundTaskSample.ServicingCompleteTaskEntryPoint,
                                                                   BackgroundTaskSample.ServicingCompleteTaskName,
                                                                   new SystemTrigger(SystemTriggerType.ServicingComplete, false),
                                                                   null);

            AttachProgressAndCompletedHandlers(task);
            UpdateUI();
        }
 /// <summary>
 /// Update the scenario UI.
 /// </summary>
 private async void UpdateUI()
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () =>
     {
         RegisterButton.IsEnabled   = !BackgroundTaskSample.ServicingCompleteTaskRegistered;
         UnregisterButton.IsEnabled = BackgroundTaskSample.ServicingCompleteTaskRegistered;
         Progress.Text = BackgroundTaskSample.ServicingCompleteTaskProgress;
         Status.Text   = BackgroundTaskSample.GetBackgroundTaskStatus(BackgroundTaskSample.ServicingCompleteTaskName);
     });
 }
        /// <summary>
        /// Register a ApplicationTriggerTask.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RegisterBackgroundTask(object sender, RoutedEventArgs e)
        {
            trigger = new ApplicationTrigger();

            var task = BackgroundTaskSample.RegisterBackgroundTask(BackgroundTaskSample.SampleBackgroundTaskEntryPoint,
                                                                   BackgroundTaskSample.ApplicationTriggerTaskName,
                                                                   trigger,
                                                                   null);
            await task;

            AttachProgressAndCompletedHandlers(task.Result);
            UpdateUI();
        }
 /// <summary>
 /// Update the scenario UI.
 /// </summary>
 private async void UpdateUI()
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () =>
     {
         RegisterButton.IsEnabled   = !BackgroundTaskSample.ApplicationTriggerTaskRegistered;
         UnregisterButton.IsEnabled = BackgroundTaskSample.ApplicationTriggerTaskRegistered;
         SignalButton.IsEnabled     = BackgroundTaskSample.ApplicationTriggerTaskRegistered & (trigger != null);
         Progress.Text = BackgroundTaskSample.ApplicationTriggerTaskProgress;
         Result.Text   = BackgroundTaskSample.ApplicationTriggerTaskResult;
         Status.Text   = BackgroundTaskSample.GetBackgroundTaskStatus(BackgroundTaskSample.ApplicationTriggerTaskName);
     });
 }
        /// <summary>
        /// Register a TimeTriggeredTask.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RegisterBackgroundTask(object sender, RoutedEventArgs e)
        {
            //
            // Time triggered tasks can only run when the application is on the lock screen.
            // Time triggered tasks can be registered even if the application is not on the lockscreen.
            //
            await BackgroundExecutionManager.RequestAccessAsync();

            var task = BackgroundTaskSample.RegisterBackgroundTask(BackgroundTaskSample.SampleBackgroundTaskEntryPoint,
                                                                   BackgroundTaskSample.TimeTriggeredTaskName,
                                                                   new TimeTrigger(15, false),
                                                                   null);

            AttachProgressAndCompletedHandlers(task);
            UpdateUI();
        }
 /// <summary>
 /// Unregister a ServicingCompleteTask.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void UnregisterBackgroundTask(object sender, RoutedEventArgs e)
 {
     BackgroundTaskSample.UnregisterBackgroundTasks(BackgroundTaskSample.ServicingCompleteTaskName);
     UpdateUI();
 }
 /// <summary>
 /// Unregister a ApplicationTriggerTask.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void UnregisterBackgroundTask(object sender, RoutedEventArgs e)
 {
     BackgroundTaskSample.UnregisterBackgroundTasks(BackgroundTaskSample.ApplicationTriggerTaskName);
     BackgroundTaskSample.ApplicationTriggerTaskResult = "";
     UpdateUI();
 }