Ejemplo n.º 1
0
        /// <summary>
        /// Uses the LocationHelper class to check monitored locations
        /// and raise a notification if the travel time has increased.
        /// </summary>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
            bool isCanceled = false;

            taskInstance.Canceled += (s, e) => isCanceled = true;
            try
            {
                if (isCanceled)
                {
                    deferral.Complete();
                    return;
                }
                await LocationHelper.CheckTravelInfoForMonitoredLocationsAsync();
            }
            finally
            {
                deferral.Complete();
            }
        }