I have a windows 8 metro app that displays data on a live tile which is refreshed every minute.
When the metro app is started it creates a sequence to do the tile updates. This works perfectly.
The problem:
When I restart my computer the metro tile stops working. Instead it goes back to the default metro tile (app name bottom left image middle).
I can get it to work again by simply starting and stopping the metro app. But I do not wish to do this.
I implement a class that implements IBackgroundTask and implements the run method.
public void Run(IBackgroundTaskInstance taskInstance){
BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
TileScheduler.CreateSchedule();
deferral.Complete();
}
In the metro app package manifest added declaration “Background Task” and under entry point pointed to this class. I also register timer and system event.
This class code basically calls the same code path the main app does when setting the tile sequence for the first time except that it is wrapped with a deferral.
The Question
Is this the right path (as it doesn’t seem to be working so I guess my implementation is wrong)? or is there a better way to do this?
This might just be a case of “you can’t do that with a simulated program”. I’m assuming you are doing this by running the app using a developers license in visual studio. My understanding of how the tiles updating works (correct me if I’m wrong) but the tiles poll a website to get the next item to display. Since you’ve bounced your box any visual studio spun up services like an ASP.net host etc will not be running so the tile won’t be able to get its new update.
If you want to test the functionality before deploying to the store I’d suggest in your project deploying your web service to IIS not to the test environment and configuring IIS to host that service at startup.