我正在开发一个 wp8 应用程序,它会拍一张照片,然后带你到下一个屏幕来决定你是否喜欢它。目前的做法是这样的:
private void ShutterButton_Click(object sender, RoutedEventArgs e)
{
if (cam != null)
{
try
{
cam.CaptureImage();
await Task.Delay(1500);
NavigateFront();
}
catch (Exception ex)
{
...
}
}
}
public void NavigateFront()
{
string naviString = "/confirmPicture.xaml?parameter=" + fileName.ToString();
_rootFrame.Navigate(new Uri(naviString, UriKind.Relative));
}
在我的 Lumia 520 上,它有时会崩溃。如果我将等待时间增加到 2.5 秒,它会起作用。但当然这不应该是这样做的方式。
如果我捕捉到void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
-Event 并在一切完成并且所有流都关闭后尝试导航,我仍然会进入NavigateFailed
-State 并且应用程序崩溃。
我的问题是:是否有任何其他有用的事件可以确保完成所有工作并且我可以在不使用基于时间的静态值的情况下进行导航?