0

I have a Windows Phone 7 application that currently uses Live Tile Schedules to update.

The new version of the app uses a background task to update the tiles.

However after upgrading the app on a phone, if a tile schedule is already running on the main tile it doesn't stop updating.

I need to stop the tile schedule if it is running.

Creating a new schedule and stopping it doesn't work:

var t = new ShellTileSchedule()
                {
                    MaxUpdateCount = 1,
                    Recurrence = UpdateRecurrence.Onetime,
                    StartTime = DateTime.Now,
                    RemoteImageUri = new Uri("http://mysite.com/livetile.png"),
                };
t.Start();
t.Stop();

Creating a new schedule on the main tile in Active Tiles doesn't work:

ShellTile mainTile = ShellTile.ActiveTiles.FirstOrDefault();
t = new ShellTileSchedule(mainTile)
                    {
                        MaxUpdateCount = 1,
                        Recurrence = UpdateRecurrence.Onetime,
                        StartTime = DateTime.Now,
                        RemoteImageUri = new Uri("http://mysite.com/livetile.png")
                     };
t.Start();
t.Stop();
Doug
  • 6,460
  • 5
  • 59
  • 83

2 Answers2

2

Since you can only have one ShellTileSchedule per application, creating a new one, starting it, and then stopping it, should remove the old one, and of course stop the one you just created.

(Why didn't you try before asking?)

Claus Jørgensen
  • 25,882
  • 9
  • 87
  • 150
  • two reasons for not trying. Thought there should be an SO page with the correct answer as I couldn't find it easily on MSDN and also because I didn't want to use a hack, I wanted to ensure I used the correct way – Doug Dec 27 '11 at 23:09
  • MSDN clarifies there can only be *one* `ShellTileSchedule` per page, so :-) – Claus Jørgensen Dec 28 '11 at 11:33
  • This solution of creating a new one and stopping it doesn't appear to work...? – Doug Dec 30 '11 at 11:51
1

First of all, is this problem occurring in an app that is actually deployed to the marketplace? (by that I mean, is the update deployed?) If it isn't this might have to do with the way the actual deployment of developer apps to a phone works.

Here's some other suggestions, I haven't tested any of them: - Have you tried removing from your app? It's required for the ShellTileSchedule so removing it might stop it from working? This would probably happen automatically when submitting this app through the marketplace, but for testing you could give it a shot. - A ShellTileScheduel can be cancelled if it fails. If possible, could you try to remove the PNG file that's in the RemoteImageUri. Or fill it with broken data to mess the ShellTileSchedule up. I know this isn't pretty, but it might work. - Have you tried replacing the ShellTileSchedule with one that's not indefinitely recurring? Just make it execute (one last time) and then it finishes.

Good luck with it and please let us know if and how you fixed.

Tom Verhoeff
  • 1,270
  • 6
  • 12
  • Thanks Tom. some great ideas, although sadly i am unable to "screw up" the live tile as it will break all people who haven't updated to the new version once its in the marketplace (i am fixing this in future by having versioned live tile handlers). I have also tried starting a single schedule (in the code in the question) without any luck. hence my rising frustration. You are probably onto something with the manifest "update" that visual studio does during deployment if you haven't run a "Clean, Rebuild" - this is how i test my updates; by installing each in order after doing a Clean Rebuild. – Doug Jan 08 '12 at 00:40
  • 1
    Hmm, there's two options I can think of: - Track when a user runs the updated version for the first time and then break the original live tile - When the update gets published replace all "old" tiles with a "please update" message and break it after a day or so. The message will remain visible until a user updates and the background agent starts running. Both are not ideal, but unfortunately the best I can think of right now. Keep us posted! – Tom Verhoeff Jan 08 '12 at 01:41