1

I have an wp8 app using PeriodicTask background Agent.

The task update the information of multiple live tiles, using POST Client to get title and image url from my server to update the live tile.

Background agent works just fine in debugging and releasing mode. When the .xap file was deployed into my device using XAPDeployement tool, the background Agent also works perfectly.

However, it won't work after submitted to wp app store, no matter it's beta version or not. If the app is downloaded from store, the background agent has never worked, and it is blocked by system after a few minutes.

How come it goes wrong since the XAP files are the same?

part of code:

public static Task<string> jsonPostClientTask(Dictionary<string, object> parameters, string url)
    {
        var results = new TaskCompletionSource<string>();
        PostClient proxy = new PostClient(parameters);
        try
        {
            proxy.DownloadStringCompleted += (sender, e) =>
            {
                if (e.Error == null)
                {
                    string response = e.Result.ToString();
                    results.TrySetResult(response);
                }
                else
                {
                    results.TrySetResult("");
                    results.TrySetException(e.Error);
                }

            };
            proxy.DownloadStringAsync(new Uri(url));
        }
        catch
        {
            results.TrySetResult("");
        }
        return results.Task;
    }

ScheduledAgent class:

  protected override void OnInvoke(ScheduledTask task)
    {
        foreach (var tile in tileList)
        {
            string dataString = jsonPostClientTask(parameters, url);

            //update tile in used
            FlipTileData tileData = new FlipTileData()
            {
                BackContent = "string content",
                WideBackContent = "string back content",

                BackBackgroundImage = new Uri("http://xxxx.xxx/xxx.png", UriKind.RelativeOrAbsolute),
                WideBackBackgroundImage = new Uri("http://xxxx.xxx/xxx.png", UriKind.RelativeOrAbsolute),
            };

            ShellTile primaryTile = ShellTile.ActiveTiles.First();
            if (primaryTile != null)
                primaryTile.Update(tileData);
        }


    }
superwave
  • 180
  • 1
  • 8
  • I'm having the same issue right now. Did you find what was going wrong? – Thomas Oct 08 '14 at 11:17
  • nope, still can't solve it – superwave Oct 14 '14 at 10:20
  • I found my error. I didn't remove the "#define DEBUG_AGENT" statement prior to uploading the app, so when the app ran into the ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60)); statement (which is illegal for live apps), the background agent crashed. – Thomas Oct 14 '14 at 13:00

0 Answers0