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 async override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            BgTaskHelper.RemoveSentDocs();
            await BgTaskHelper.SendPendingDocs();

#if DEBUG_AGENT
            // If debugging is enabled, launch the agent again in one minute.

            string toastMessage = "WP2Reader BG Task running";
            // Launch a toast to show that the agent is running.
            // The toast will not be shown if the foreground application is running.
            ShellToast toast = new ShellToast();
            toast.Title   = "WPToReader";
            toast.Content = toastMessage;
            toast.Show();
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
#endif
            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
Ejemplo n.º 2
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private async void Application_Launching(object sender, LaunchingEventArgs e)
 {
     BgTaskHelper.RemoveSentDocs();
     await BgTaskHelper.SendPendingDocs();
 }