How can I make the background agent execution to wait before all ImageOpened()
events are fired (3 in this case) in order to update secondary live tile with custom images?
Edit 1:
In the OnInvoke()
method of the ScheduledAgent
I am calling my own create tile data function implemented in a shared library which in turn subscribes to 3 ImageOpened()
events as I am trying to create custom images for all live tile templates i.e. small, medium and wide.
Since these being asynchronous events I have no way to check if all the events have completed successfully so that I can call NotifyComplete()
to notify the background agent that its job is now done. So sometimes the tile gets updated while most of the times it doesn't. Also I am using the same function to update the live tiles every time the app is launched so there is no problem with its implementation. I have also tried to take care of all the memory limitations with the ScheduledAgent by disposing Bitmaps and calling GC.Collect()
forcefully.
Please help in any possible way to fix this problem.
Add a new class that lets you create custom events -
Initialize the events and required variables in the file you are updating the custom live tile from -
Fire the completion event in the
ImageOpened()
event handlers for all the tiles and check if theSaveAllImagesComplete
event needs to be fired-In the ScheduledAgent file -
In the OnInvoke() function -