Beispiel #1
0
 private async Task RunBackgroundTask(IBackgroundTask task, IDeferral deferral)
 {
     try
     {
         await task.RunAsync();
     }
     catch (Exception ex)
     {
         Debug.WriteLine($"AppModel: Background task \"{task.Id}\" failed: {ex}");
     }
     finally
     {
         deferral.EndDeferral();
     }
 }
Beispiel #2
0
        public void Initialize(IAppTaskInstance task)
        {
            if (_initialized)
            {
                return;
            }

            task.Canceled += Task_Canceled;

            var triggerDetails = task.TriggerDetails;

            _deferral = task.GetDeferral();

            _connection = triggerDetails.AppServiceConnection;

            _connection.RequestReceived += Connection_RequestReceived;
            _connection.ServiceClosed   += Connection_ServiceClosed;

            _initialized = true;
        }
Beispiel #3
0
 /// <summary>
 /// Creates a new <see cref="BackgroundActivatedEventArgs"/>.
 /// </summary>
 /// <param name="taskName">The identifiable name of the background task that should be executed.</param>
 /// <param name="deferral">An <see cref="IDeferral"/> that can be used for managing this background task.</param>
 public BackgroundActivatedEventArgs(string taskName, IDeferral deferral)
 {
     TaskName = taskName;
     Deferral = deferral;
 }