The problem





When I upgraded my WP7 projects to Windows Phone 8, I discovered a strange behavior.

I usually update the tiles in the Application_Deactivated and Application_Closing event, but in wp8 the app crashes while it resumes.

The tiles were created in the storage, so all works good.

The problem seems related to the WriteableBitmap.Render method. I don't know why it blocks the UI thread!



The workaround





In the App.xaml.cs add the Navigating event in the InitializePhoneApplication method




RootFrame.Navigating += RootFrame_Navigating;




Use the app://external/ string to know when you are exiting from the application 







void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
{
    if(e.Uri.OriginalString=="app://external/")
    {
        // update my custom tiles
    }
}