Ejemplo n.º 1
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            UpdateTile.Start();

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
Ejemplo n.º 2
0
        private void SetUpNotifications()
        {
            // Update live title anyway:
            UpdateTile.Start();

            periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;

            // If the task already exists and background agents are enabled for the
            // application, you must remove the task and then add it again to update
            // the schedule
            if (periodicTask != null)
            {
                RemoveAgent(periodicTaskName);
            }

            try
            {
                periodicTask = new PeriodicTask(periodicTaskName);
                // The description is required for periodic agents. This is the string that the user
                // will see in the background services Settings page on the device.
                periodicTask.Description = "This is the Live Tile support for the Days Until Xmas application. Live tiles will not work without this running.";

                ScheduledActionService.Add(periodicTask);
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show(
                        "Background agents for this application have been disabled by the user. Please enable for Live Tiles.",
                        "Whoops!", MessageBoxButton.OK);
                }
            }
        }