Monday, April 1, 2013 #

Updated Windows Blog Reader Sample with Background Task

I had earlier posted the Blog Reader Sample with Search Implementation.  The Blog Reader is an excellent place to start to build XAML Windows 8 Apps. I had customized it to include Search and a few other things.

As much as we would love to open the Blog Reader and have it running all the time to check new feeds, it would be nice if we can get those as a part of the Live Tiles.  Live Tiles in Windows 8 allows people to get a peek of what’s happening new and thereafter pre-empts the users to click the Live Tile and get into the application to read the rest of the stuff.

image

Above is my Start screen in which you can see there are Live Tiles for most of the apps including Travel App which has an exciting location picture which induces me to click and find more about the place.

Now, for our Blog Reader sample, we can implement Live Tile such that it keeps checking for new feeds and presents it within our Tile.  Once I find something interesting, I can click and launch the Blog Reader to read about the same.

This obviously involves a service running in the background and keep poling the feeds.  That would make it an ideal candidate for background task.  Background Tasks in Windows 8 allows a process to run in the background while the app may/may not be active.  They are very handy in a variety of scenarios, particularly for the fact that Apps in Windows 8 gets pushed to suspended state in 2 seconds and there is really no way to keep them running infinitely and keep checking for new stuff.

In our case, I have added a Background Task Project and a class which implements the Run method to keep checking for the feeds.  This is based on the Background Task Sample QuickStart

The actual implementation is 3 methods in the Background Task and a method in the ItemsPage.xaml in the main project.

In principle with DRY (Do not Repeat), I am going to again point to the link here

The only change I have made is to make the feed check the ASP.NET Main Page RSS Feed.

You can download the completed project from here

Cheers !!!

Posted On Monday, April 1, 2013 8:44 AM | Comments (12)