0

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?

Choco Smith
  • 1,658
  • 18
  • 24

1 Answers1

1

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.

Mike
  • 418
  • 3
  • 10
  • hey It seems logical what you are saying, I don't use an IIS service but will run a release check soon to see if its a debug environment issue. many thanks for your help – Choco Smith Jan 09 '13 at 11:01
  • Oh another thing you can try is running your application with the simulator. I've noticed that if I do the gesture to close my app in the simulator that visual studio things my debug session is done but my WCF services at least stay alive. When I'm back to the simulated desktop I can launch my app again and it is like it is a new session but visual studio isn't aware that I'm still playing around with my project. Works good enough to see that data is getting persisted for example. You could see if your tile works on "reboot" if you close the app, launch it again then go back to the start menu. – Mike Jan 14 '13 at 01:43
  • 1
    Damm I thought this would work but the simulator won't let me add background task. Not sure why Microsoft restricted this as it was fine pre RC. "WinRT information: You can’t change background task and lock screen privileges while running this application in the simulator." We got a beta release coming out soon, I guess I'll just need budget more time for errors in the background task section :D – Choco Smith Jan 14 '13 at 14:02