I'm writing a BackgroundAgent
for my WP7 app that periodically downloads an image from the internet, modifies it, then updates the live tile with it. I've found that loading the bitmap image is asynchronous, and requires registering the ImageOpened
event.
sourceBitmap.ImageOpened += new EventHandler<RoutedEventArgs>((sender, e) => ...
The problem is that this brings me off of the main thread, which will return back to the ScheduledAgent and call NotifyComplete()
before the new thread has finished. I assume this will cause problems and is not ideal.
Is there a way to have the main thread wait until the image is loaded, edited, and pushed to the live tile?
Or should I just use a field IsComplete
and Thread.Sleep()
until it is true?