コード例 #1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            this.Deferral          = taskInstance.GetDeferral();
            taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnTaskCancelled);

            try {
                AppUpdater updater   = new AppUpdater();
                bool       mandatory = await updater.IsMandatoryUpdateAvailableAsync(setFlag : true);

                /**
                 * Unregister non-essential tasks when there is a mandatory update
                 *
                 * if (mandatory) {
                 *     // Unregister non-essential tasks
                 * }
                 */
                Debug.WriteLine("CheckStoreUpdatesTask: Mandatory updates available: " + mandatory);
            } catch (Exception e) {
                Debug.WriteLine("ERROR: CheckStoreUpdatesTask: Run: " + e.Message);
            } finally {
                this.Deferral.Complete();
            }
        }