【发布时间】:2013-07-10 15:45:11
【问题描述】:
好的,我在 wp7 应用程序中有以下内容。我正在使用 Microsoft.Bcl 和 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
}
}
我在if(LoggedIn) 和NavigationService.Navigate 设置断点只是为了看看它是否到达那里并且它确实到达了,但是代码中的MessageBox 没有显示并且放置断点不会中断,表明它没有到达那么远。我还在RootFrame_Navigating 中设置了一个断点,它也没有到达那里。
关于它为什么会卡在 Navigate 的任何想法?
编辑:问题已解决
我将导航放在Dispatcher.BeginInvoke 中,现在它可以工作了。
this.Dispatcher.BeginInvoke(() =>
{
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
});
【问题讨论】:
标签: c# windows-phone-7 async-await navigationservice