Search code examples
push-notificationrssbackground-task

Reading SyndicationFeed in background


Uri uri = new Uri( feedUri);
            SyndicationClient client = new SyndicationClient();
            SyndicationFeed currentFeed = await client.RetrieveFeedAsync(uri);
            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText03);
            XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");
            toastTextElement[0].AppendChild(toastXml.CreateTextNode("Working"));
            ToastNotification toast = new ToastNotification(toastXml);
            ToastNotificationManager.CreateToastNotifier().Show(toast);

nothing is being executed after RetrieveFeedAsync.


Solution

  • try to add deferal to your Running Background

    public async void Run(IBackgroundTaskInstance taskInstance)
        {
    
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
    
            //YOUR CODE GOES HERE           
    
            deferral.Complete();
    
        }