1

Ok I have the following in a wp7 app. I am using Microsoft.Bcl and Microsoft.Bcl.Async.

async void FB_Login()
{
   Bool LoggedIn = false;

   LoggedIn = await LoginToFB();

   if(LoggedIn)
   {
      SaveProfile();

      NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));   // Code does reach this point but does not navigate

      MessageBox.Show("Navigating");   // Code does not reach here
   }
}

I put break points in at if(LoggedIn) and at NavigationService.Navigate just to see if it reaches there and it does but the MessageBox in the code does not show and putting in a breakpoint does not break indicating its not reaching that far. I also put in a break point in RootFrame_Navigating and it doesn't reach there either.

Any ideas as to why its getting stuck at Navigate?

Edit: Problem solved

I put the navigation in a Dispatcher.BeginInvoke and now it works.

this.Dispatcher.BeginInvoke(() =>
{
   NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
 });
svick
  • 236,525
  • 50
  • 385
  • 514
Gaz83
  • 2,293
  • 4
  • 32
  • 57

1 Answers1

1

Try to extract navigate logic from this method.

Sergiy Kozachenko
  • 1,399
  • 11
  • 31