WebBrowserTask bug when pressing the back button very quickly (WP7)
I have a WebBrowserTask which is called when a button is clicked:
private void button1_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.URL = "http://msdn.microsoft.com";
webBrowserTask.Show();
}
when i click this button in my app, and then I click the back button of the device very quick开发者_Go百科ly, my app crashes, and the Application_Activated() method doesn't even called..
Is this a bug of the SDK? You can reproduce the problem very easily on the emulator or on your device.
Any workarounds? This seems to happen in all tasks (sms, email etc).
Thank you
Are you sure it's your Application_Activated being skipped and not your Constructor?
If it's crashing because your constructors not being called it's likely you've restarted your app fast enough for it to have not been tombstoned as Peter describes in more detail here.
How to correctly handle application deactivation and reactivation - Peter Torr's Blog
If this isn't the case either, is it possible your app wasn't initially created using the RTM tools and needs to be migrated per the new project templates?
Navigating to another page/task is not a synchronous process where you call the page and wait for a return result. If you are fast enough, you close your application the normal way before the task even startet.
精彩评论