Exemple #1
0
        /// <summary>
        /// Runs the tile updater service.
        /// </summary>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            CancellationTokenSource tokenSource = new CancellationTokenSource();

            taskInstance.Canceled += (sender, reason) => tokenSource.Cancel();

            try
            {
                await TileUpdaterService.UpdateTilesAsync(tokenSource.Token);
            }
            finally
            {
                deferral.Complete();
                tokenSource.Dispose();
            }
        }
Exemple #2
0
        /// <summary>
        /// Runs the tile updater service.
        /// </summary>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            // Try and register the rest of our background tasks:
            BackgroundTaskRegistrar.TryRegisterAllBackgroundTasks();

            var deferral = taskInstance.GetDeferral();

            CancellationTokenSource tokenSource = new CancellationTokenSource();

            taskInstance.Canceled += (sender, reason) => tokenSource.Cancel();

            try
            {
                await TileUpdaterService.UpdateTilesAsync(tokenSource.Token);
            }
            finally
            {
                deferral.Complete();
                tokenSource.Dispose();
            }
        }