Example #1
0
 private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     AppServiceDeferral?.Complete();
     AppServiceDeferral = null;
     Connection         = null;
     AppServiceDisconnected?.Invoke(this, null);
 }
Example #2
0
        /// <summary>
        /// Event that is triggered when the task is cancelled.
        /// </summary>
        /// <param name="sender">The task instance cancelling the task.</param>
        /// <param name="reason">The reason for cancellation.</param>
        private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            try
            {
                Logging.Append(string.Format("Background task for trigger type '{0}' was cancelled due to '{1}.", _triggerType, reason));

                _deferral?.Complete();
            }
            finally
            {
                _deferral = null;
            }
        }
Example #3
0
        private async Task ClearPaymentsAsync()
        {
            var settingsFacade = new SettingsFacade(new SettingsAdapter());

            try
            {
                taskInstance.Progress = 10;

                var mediator = ServiceLocator.Current.GetInstance <IMediator>();
                await mediator.Send(new ClearPaymentsCommand());

                taskInstance.Progress = 100;
            }
            catch (Exception ex)
            {
                logManager.Error(ex, "ClearPaymentTask stopped due to an error.");
            }
            finally
            {
                settingsFacade.LastExecutionTimeStampClearPayments = DateTime.Now;
                logManager.Debug("ClearPaymentTask finished.");
            }

            deferral?.Complete();
        }
Example #4
0
 public void CloseVoipTask()
 {
     Debug.WriteLine($"{DateTime.Now} VoipTask closed.");
     Hub.Instance.VoipTaskInstance = null;
     _deferral?.Complete();
     _deferral = null;
 }
Example #5
0
        private async Task SynBackupAsync()
        {
            var settingsFacade = new SettingsFacade(new SettingsAdapter());

            if (!settingsFacade.IsBackupAutouploadEnabled || !settingsFacade.IsLoggedInToBackupService)
            {
                return;
            }

            try
            {
                taskInstance.Progress = 10;

                var backupService = ServiceLocator.Current.GetInstance <IBackupService>();
                await backupService.RestoreBackupAsync();

                var mediator = ServiceLocator.Current.GetInstance <IMediator>();
                await mediator.Send(new ClearPaymentsCommand());

                await mediator.Send(new CreateRecurringPaymentsCommand());

                taskInstance.Progress = 100;
            }
            catch (Exception ex)
            {
                logManager.Error(ex, "Sync Backup failed.");
            }
            finally
            {
                settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now;
                logManager.Debug("Sync Backup finished.");
            }

            deferral?.Complete();
        }
Example #6
0
        public override Task RunAsyncInternal(IBackgroundTaskInstance taskInstance)
        {
            if (taskInstance == null)
            {
                return(null);
            }

            _deferral = taskInstance.GetDeferral();

            return(Task.Run(async() =>
            {
                //// TODO WTS: Insert the code that should be executed in the background task here.
                //// This sample initializes a timer that counts to 100 in steps of 10.  It updates Message each time.

                //// Documentation:
                ////      * General: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/support-your-app-with-background-tasks
                ////      * Debug: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/debug-a-background-task
                ////      * Monitoring: https://docs.microsoft.com/windows/uwp/launch-resume/monitor-background-task-progress-and-completion

                //// To show the background progress and message on any page in the application,
                //// subscribe to the Progress and Completed events.
                //// You can do this via "BackgroundTaskService.GetBackgroundTasksRegistration"

                _logHelper.Log(LogLevel.Info, "Entered background task");

                _taskInstance = taskInstance;

                //Singleton<PrintQueue>.Instance.RestorePrintQueue();

                await PrintQueue.Instance.PrintToDestinationsAsync();

                _deferral?.Complete();
            }));
        }
Example #7
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            try
            {
                var triggerDetail = (AppServiceTriggerDetails)taskInstance.TriggerDetails;
                // Keep a deferral to prevent the task from terminating.
                _deferral = taskInstance.GetDeferral();

                // Save this connection in the hub.  It will be used for bidirectional communication.
                Hub.Instance.ForegroundConnection = triggerDetail.AppServiceConnection;
                Hub.Instance.ForegroundTask       = this;

                taskInstance.Canceled += (s, e) => Close();
                triggerDetail.AppServiceConnection.ServiceClosed += (s, e) => Close();
            }
            catch (Exception e)
            {
                _deferral?.Complete();
                if (Hub.Instance.IsAppInsightsEnabled)
                {
                    Hub.Instance.RtcStatsManager.TrackException(e);
                }
                throw;
            }
        }
Example #8
0
 protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
 {
     base.OnBackgroundActivated(args);
     if (args.TaskInstance.TriggerDetails is AppServiceTriggerDetails details)
     {
         if (details.CallerPackageFamilyName == Package.Current.Id.FamilyName)
         {
             try
             {
                 _appServiceDeferral         = args.TaskInstance.GetDeferral();
                 args.TaskInstance.Canceled += (s, e) =>
                 {
                     _appServiceDeferral?.Complete();
                     _appServiceDeferral = null;
                     Connection          = null;
                     AppServiceDisconnected?.Invoke(this, null);
                 };
                 Connection = details.AppServiceConnection;
                 AppServiceConnected?.Invoke(this, args.TaskInstance.TriggerDetails as AppServiceTriggerDetails);
                 _logger.Info("辅助进程服务连接成功");
             }
             catch (Exception ex)
             {
                 _logger.Error("辅助进程服务连接失败");
                 _logger.Error(ex);
             }
         }
     }
     else
     {
         _logger.Error("辅助进程服务连接失败");
         _logger.Error(args.TaskInstance.TriggerDetails.GetType());
     }
 }
Example #9
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            try
            {
                serviceDeferral        = taskInstance.GetDeferral();
                taskInstance.Canceled += OnTaskCanceled;

                ExecutingPlatform.Current = AppPlatform.UWP;
                var context = new EfCoreContext();
                var utData  = context.SetupSingleDtoAndEntities <AccountViewModel>();
                utData.AddSingleDto <CategoryViewModel>();
                utData.AddSingleDto <PaymentViewModel>();
                utData.AddSingleDto <RecurringPaymentViewModel>();

                var crudService = new CrudServicesAsync(context, utData.ConfigAndMapper);

                var liveTileManager = new LiveTileManager(crudService);
                await liveTileManager.UpdatePrimaryLiveTile();

                await liveTileManager.UpdateSecondaryLiveTiles();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Debug.WriteLine("LiveTile update failed.");
            }
            finally
            {
                serviceDeferral?.Complete();
            }
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            deferral = taskInstance.GetDeferral();
            taskInstance.Canceled += TaskInstance_Canceled;
            try
            {
                var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;
                voiceServiceConn = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails);
                var command = await voiceServiceConn?.GetVoiceCommandAsync();

                switch (command.CommandName)
                {
                case "RollCommand":
                    await ServiceCommandHandleAsync(command.SpeechRecognitionResult.SemanticInterpretation);

                    break;

                case "ShowAllCommand":
                    await FindCommandHandleAsync(command.SpeechRecognitionResult.SemanticInterpretation);

                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                deferral?.Complete();
            }
        }
Example #11
0
        private async Task RunAsyncInternal()
        {
            var stopwatch = Stopwatch.StartNew();

            try
            {
                _container.RegisterSingleton <IController>(() => this);
                _container.RegisterServices();
                _options.ContainerConfigurator?.ConfigureContainer(_container);
                _container.Verify();

                _log = _container.GetInstance <ILogService>().CreatePublisher(nameof(Controller));

                _container.GetInstance <IInterruptMonitorService>().RegisterInterrupts();
                _container.GetInstance <IDeviceRegistryService>().RegisterDevices();
                _container.GetInstance <IRemoteSocketService>().RegisterRemoteSockets();

                _container.StartupServices(_log);
                _container.ExposeRegistrationsToApi();

                await TryConfigureAsync();

                StartupCompleted?.Invoke(this, new StartupCompletedEventArgs(stopwatch.Elapsed));

                _container.GetInstance <IScriptingService>().TryExecuteStartupScripts();
            }
            catch (Exception exception)
            {
                StartupFailed?.Invoke(this, new StartupFailedEventArgs(stopwatch.Elapsed, exception));
                _deferral?.Complete();
            }
        }
Example #12
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            try
            {
                if (Hub.Instance.VoipTaskInstance != null)
                {
                    Debug.WriteLine("VoipTask already started.");
                    return;
                }

                _deferral = taskInstance.GetDeferral();
                Hub.Instance.VoipTaskInstance = this;
                Debug.WriteLine($"{DateTime.Now} VoipTask started.");
                taskInstance.Canceled += (s, e) => CloseVoipTask();
            }
            catch (Exception e)
            {
                _deferral?.Complete();
                if (Hub.Instance.IsAppInsightsEnabled)
                {
                    Hub.Instance.RtcStatsManager.TrackException(e);
                }
                throw;
            }
        }
Example #13
0
        private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            _appServiceDeferral?.Complete();
            _appServiceDeferral   = null;
            _appServiceConnection = null;

            Application.Current.Exit();
        }
        private void OnMediaPlayerEnded(MediaPlayer sender, object args)
        {
            lc.LogMessage("OnMediaPlayerEnded");

            sender.PlaybackSession.Position = TimeSpan.Zero;
            sender.Dispose();
            _deferral?.Complete();
        }
Example #15
0
        private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            _appServiceDeferral?.Complete();
            _appServiceDeferral   = null;
            _appServiceConnection = null;

            // ReSharper disable once ArrangeStaticMemberQualifier
            Application.Current.Exit();
        }
Example #16
0
        private void Close()
        {
            VoIPCallTask.Log("Releasing background task", "Releasing VoIPCallTask");

            VoIPCallTask.Mediator.Initialize(null as AppServiceConnection);

            _current    = null;
            _connection = null;
            _deferral?.Complete();
        }
Example #17
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            serviceDeferral        = taskInstance.GetDeferral();
            taskInstance.Canceled += OnTaskCanceled;
            await CommonFunctions.UpdatePrimaryLiveTile();

            await CommonFunctions.UpdateSecondaryLiveTiles();

            serviceDeferral?.Complete();
        }
Example #18
0
        public static async Task LoadParticipatingNotifications(bool reset = true, BackgroundTaskDeferral deferral = null)
        {
            reset = reset || (_participatingResult == ApplicationTriggerResult.Allowed &&
                              _participatingResult == ApplicationTriggerResult.CurrentlyRunning);
            if (_participatingResult != ApplicationTriggerResult.CurrentlyRunning)
            {
                _participatingResult = await RunAppTriggerBackgroundTask("sync", "notifications", "online", "participating", "toast", true, reset);
            }

            deferral?.Complete();
        }
Example #19
0
        public static async Task LoadUnreadNotifications(bool reset = true, bool showToasts = true, BackgroundTaskDeferral deferral = null)
        {
            reset = reset || (_unreadResult == ApplicationTriggerResult.Allowed &&
                              _unreadResult == ApplicationTriggerResult.CurrentlyRunning);
            if (_unreadResult != ApplicationTriggerResult.CurrentlyRunning)
            {
                _unreadResult = await RunAppTriggerBackgroundTask("sync", "notifications", "online", "unread", "toast", true, reset);
            }

            deferral?.Complete();
        }
        public static async Task ShowToasts(this ICollection <Octokit.Notification> collection, BackgroundTaskDeferral deferral = null)
        {
            if (collection == null)
            {
                throw new NullReferenceException($"${nameof(collection)} cannot be null");
            }

            collection = new ObservableCollection <Octokit.Notification>(collection.OrderBy(n => n.UpdatedAt));
            var toastNotifications = ToastNotificationManager.History.GetHistory();

            if (toastNotifications != null && toastNotifications.Count > 0)
            {
                foreach (var toast in toastNotifications)
                {
                    Octokit.Notification notification = null;
                    try
                    {
                        notification = await toast.GetNotification();
                    }
                    finally
                    {
                        if (notification != null && collection != null && !collection.Any(n => n.Id == notification.Id))
                        {
                            ToastNotificationManager.History.Remove(toast.Tag, toast.Group);
                        }
                    }
                }
                toastNotifications = ToastNotificationManager.History.GetHistory();
            }
            if (collection != null && collection.Count() > 0)
            {
                foreach (var notification in collection)
                {
                    ToastNotification toast = null;
                    try
                    {
                        toast = await notification.BuildToast(ToastNotificationScenario.Reminder);
                    }
                    finally
                    {
                        if (toast != null && toastNotifications != null && !toastNotifications.Any(t => t.Tag == toast.Tag && t.Group == toast.Group))
                        {
                            ToastHelper.PopCustomToast(toast, toast.Tag, toast.Group);
                        }
                    }
                }
            }

            if (deferral != null)
            {
                deferral?.Complete();
            }
        }
Example #21
0
        /// <summary>
        /// Async method to run when the background task is executed.
        /// </summary>
        /// <param name="taskInstance">The background task instance being run.</param>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral              = taskInstance.GetDeferral();
            taskInstance.Canceled += OnTaskCanceled;

            /* Filter out multiple power change events (same state) when running on non mobile devices */
            if (_triggerType == DeviceTriggerType.PowerChange)
            {
                CheckPowerChange();

                if (!_isPowerChange)
                {
                    _deferral?.Complete();
                    _deferral = null;

                    return;
                }
            }

            Logging.Append(string.Format("Background task started for trigger type '{0}'.", _triggerType));

            /* Handling for the AppServiceConnection */
            if (_triggerType == DeviceTriggerType.AppService)
            {
                var details = taskInstance.TriggerDetails as AppServiceTriggerDetails;

                if ((details != null) && (details.AppServiceConnection != null))
                {
                    BackgroundTileEventHandler.Instance.TileOpened += OnTileOpened;
                    details.AppServiceConnection.RequestReceived   += OnRequestReceived;

                    return;
                }
            }

            /* Handling for the timer and power change triggers */
            try
            {
                taskInstance.Progress = 10;

                await RunBackgroundTask();
            }
            finally
            {
                taskInstance.Progress = 100;

                _deferral?.Complete();
                _deferral = null;
            }
        }
        void IBackgroundTask.Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            try
            {
                GetGeofenceStateChangedReports();
            }
            catch (UnauthorizedAccessException)
            {
                System.Diagnostics.Debug.WriteLine("Location permissions are disabled. Enable access through the settings.");
            }
            finally
            {
                deferral.Complete();
            }
        }
Example #23
0
 private void Timer_Tick(ThreadPoolTimer timer)
 {
     if (_cancelRequested == false)
     {
         metecDriver.checkButton();
         if (metecDriver.btn_update)
         {
             Debug.WriteLine("button " + metecDriver.btn_position + " switched to " + metecDriver.btn_state);
             metecDriver.btn_update = false;
         }
     }
     else
     {
         timer.Cancel();
         deferral.Complete();
     }
 }
Example #24
0
        protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            //LoggingChannel lc = new LoggingChannel("UCQU_BackgroundTask", null, new Guid("4bd2826e-54a1-4ba9-bf63-92b73ea1ac4a"));
            //lc.LogMessage("Background Task Activated.");
            base.OnBackgroundActivated(args);
            //lc.LogMessage("Base Handler Called.");
            IBackgroundTaskInstance taskInstance = args.TaskInstance;
            //lc.LogMessage("Task Instance Set.");
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            //lc.LogMessage("Task Deferral Obtained.");
            //lc.LogMessage("Executing Payload Method.");
            switch (args.TaskInstance.Task.Name)
            {
            case "Hourly Tile Update Task":
            case "Login Tile Update Task":
                try
                {
                    string id, pwdHash;
                    Login.LoadCredentials(out id, out pwdHash);
                    if (id == null)
                    {
                        return;
                    }

                    try
                    {
                        string token = await WebClient.LoginAsync(id, pwdHash);

                        DL444.UcquLibrary.Models.Schedule schedule = await WebClient.GetScheduleAsync(token);

                        await ScheduleNotificationUpdateTasks.UpdateTile(schedule);
                    }
                    catch (Exception) { }
                }
                catch (Exception e)
                {
                    //lc.LogMessage($"Unhandled exception thrown when executing task payload.\n\n{e.Message}\n\n{e.StackTrace}");
                }
                break;
            }
            //lc.LogMessage("Completing Deferral.");
            deferral.Complete();
            //lc.LogMessage("Task Completed.");
        }
Example #25
0
        protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            BackgroundTaskDeferral deferral = args.TaskInstance.GetDeferral();

            BackgroundTaskHelper.Current.IsRunning = true;

            try
            {
                if (!await viewModel.Api.IsAuthorized())
                {
                    return;
                }

                if (args.TaskInstance.Task.Name == BackgroundTaskHelper.TimerBackgroundTaskBuilderName)
                {
                    Settings.Current.SyncTimerTime = DateTime.Now;
                    await BackgroundTaskHelper.Current.Start(viewModel.Syncs, viewModel.Api);
                }

                Queue <SyncPairHandler> syncs = BackgroundTaskHelper.Current.Queue;
                while (syncs.Count > 0)
                {
                    SyncPairHandler handler = syncs.Dequeue();
                    await handler.Start();

                    SyncPair sync;
                    if (!handler.IsTestRun && handler.State == SyncPairHandlerState.Finished &&
                        viewModel.Syncs.TryFirst(s => s.Token == handler.Token, out sync))
                    {
                        sync.Result = handler.NewResult.ToArray();
                    }
                }
            }
            catch (Exception e)
            {
                Settings.Current.OnSyncException(e);
            }
            finally
            {
                BackgroundTaskHelper.Current.IsRunning = false;

                SaveSyncs();
                deferral.Complete();
            }
        }
        /// <summary>
        /// The background task entrypoint.
        ///
        /// Background tasks must respond to activation by Cortana within 0.5 seconds, and must
        /// report progress to Cortana every 5 seconds (unless Cortana is waiting for user
        /// input). There is no execution time limit on the background task managed by Cortana,
        /// but developers should use plmdebug (https://msdn.microsoft.com/library/windows/hardware/jj680085%28v=vs.85%29.aspx)
        /// on the Cortana app package in order to prevent Cortana timing out the task during
        /// debugging.
        ///
        /// The Cortana UI is dismissed if Cortana loses focus.
        /// The background task is also dismissed even if being debugged.
        /// Use of Remote Debugging is recommended in order to debug background task behaviors.
        /// Open the project properties for the app package (not the background task project),
        /// and enable Debug -> "Do not launch, but debug my code when it starts".
        /// Alternatively, add a long initial progress screen, and attach to the background task process while it executes.
        /// </summary>
        /// <param name="taskInstance">Connection to the hosting background service process.</param>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            // Create the deferral by requesting it from the task instance
            serviceDeferral = taskInstance.GetDeferral();

            AppServiceTriggerDetails triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;

            if (triggerDetails != null && triggerDetails.Name.Equals("VitWifiVoiceCommandService"))
            {
                voiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails);

                VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync();

                // Perform the appropriate command depending on the operation defined in VCD
                switch (voiceCommand.CommandName)
                {
                case "Login":
                    string x = NetworkNames.ToString();
                    VoiceCommandUserMessage userMessage = new VoiceCommandUserMessage();
                    userMessage.DisplayMessage = string.Format("The current networks is {0} ", x);
                    userMessage.SpokenMessage  = string.Format("The current networks is {0} ", x);

                    VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userMessage, null);
                    await voiceServiceConnection.ReportSuccessAsync(response);

                    break;

                case "Logout":
                    string logoutMessage = NetworkNames.ToString();
                    VoiceCommandUserMessage userLogoutMessage = new VoiceCommandUserMessage();
                    userLogoutMessage.DisplayMessage = string.Format("The current networks is {0} ", logoutMessage);
                    userLogoutMessage.SpokenMessage  = string.Format("The current networks is {0} ", logoutMessage);
                    VoiceCommandResponse logoutResponse = VoiceCommandResponse.CreateResponse(userLogoutMessage, null);
                    await voiceServiceConnection.ReportSuccessAsync(logoutResponse);

                    break;

                default:
                    break;
                }
            }

            // Once the asynchronous method(s) are done, close the deferral
            serviceDeferral.Complete();
        }
Example #27
0
        private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            try
            {
                if ((sender.TriggerDetails as AppServiceTriggerDetails)?.AppServiceConnection is AppServiceConnection DisConnection)
                {
                    try
                    {
                        DisConnection.RequestReceived -= Connection_RequestReceived;

                        lock (Locker)
                        {
                            if (PairedConnections.TryRemove(DisConnection, out AppServiceConnection ServerConnection))
                            {
                                Task.WaitAny(ServerConnection.SendMessageAsync(new ValueSet {
                                    { "ExecuteType", "Execute_Exit" }
                                }).AsTask(), Task.Delay(2000));
                            }
                            else if (PairedConnections.FirstOrDefault((Con) => Con.Value == DisConnection).Key is AppServiceConnection ClientConnection)
                            {
                                if (PairedConnections.TryRemove(ClientConnection, out _))
                                {
                                    Task.WaitAny(ClientConnection.SendMessageAsync(new ValueSet {
                                        { "ExecuteType", "FullTrustProcessExited" }
                                    }).AsTask(), Task.Delay(2000));
                                    ClientConnection.Dispose();
                                }
                            }
                        }
                    }
                    finally
                    {
                        DisConnection.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error was threw in CommunicateService: {ex.Message}");
            }
            finally
            {
                Deferral.Complete();
            }
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();

            var settings = new Settings();

            if (settings.NotificationsEnabled)
            {
                await SendNotificationAsync();
            }

            if (settings.UpdatingLiveTileEnabled)
            {
                await UpdateTilesAsync();
            }

            _deferral.Complete();
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            // Get a deferral, to prevent the task from closing prematurely
            // while asynchronous code is still running.
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            // Download the feed.
            InfoExport info = GetCoronaInfo();

            //var feed = await GetCoronaData();

            // Update the live tile with the feed items.
            await UpdateAsync(info);

            CoronaSpeakAsync();
            // Inform the system that the task is finished.
            deferral.Complete();
        }
Example #30
0
        public override Task RunAsyncInternal(IBackgroundTaskInstance taskInstance)
        {
            if (taskInstance == null)
            {
                return(null);
            }

            _deferral = taskInstance.GetDeferral();

            return(Task.Run(async() =>
            {
                var settings = await Settings.GetSettings();

                await ImageSetter.UpdateImages(settings);

                _deferral?.Complete();
            }));
        }