I want to update my Secondary Tiles via a Background Task. My problem is, that iterating through all pinned tiles with SecondaryTile.FindAllAsync(); fails and exits my Background Task with code 1.
I have no idea, why it is not possible to do that, why I don’t get any exceptions and why this works within the main app. Could this be a memory problem?
My code looks like this:
public sealed class SecondaryTileUpdater : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
var list = await SecondaryTile.FindAllAsync(); // Here it fails :(
foreach (SecondaryTile liveTile in list)
{
// Update Secondary Tiles
// (...)
}
}
}
This is the error I get:
The program '[5644] backgroundTaskHost.exe: Managed (v4.0.30319)' has exited with code 1 (0x1).
Any ideas, what could be reasons for this?
Thank you for any help!
Once your async method awaits, your task is ending. Request a deferral to give your asynchronous code time to execute.