我正在使用相机为我的Windows Phone创建我的第一个应用程序。在关机时,我想调用一个dispose方法从MediaCapture object
释放资源。但是我找不到在应用程序关闭时触发的事件。应用程序关机时的事件Windows Phone 8.1
有谁知道我可以在关机时处理这个对象吗?当关闭应用程序时导致手机冻结。
我正在使用相机为我的Windows Phone创建我的第一个应用程序。在关机时,我想调用一个dispose方法从MediaCapture object
释放资源。但是我找不到在应用程序关闭时触发的事件。应用程序关机时的事件Windows Phone 8.1
有谁知道我可以在关机时处理这个对象吗?当关闭应用程序时导致手机冻结。
在你app.xaml.cs你通常得到这个类
public sealed partial class App : Application
里面你有两个interresting方法已经在那里当你创建项目
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// some code here
// will run when app launch
}
而这一次
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
// some code here
}
因此,您可以在解释功能的摘要中阅读,它在用户暂停时调用e应用程序,但是您不知道应用程序是否会终止或稍后恢复,我认为您没有办法区分。
所以我建议处置OnSuspending功能
如果你想要做的是,在一个WPF项目,你实际上得到的也就是Windows Phone的8.1和Windows 8.1 Metro风格的应用程序
里面你ressources
OnExit(ExitEventArgs e)
看到MSDN文档这里(为WPF只)
我有一个预感,你不得不使用这种方法,但我想确定。感谢您的帮助,我的手机不再冻结,因为我现在可以正确处置。非常感谢你 – Tokfrans 2014-10-07 07:58:32
您是针对* Silverlight *还是* Runtime *? – Romasz 2014-10-07 07:25:03
@Romasz哈哈我不确定其实......我如何检查我的目标是什么? – Tokfrans 2014-10-07 07:28:32
例如在* Solution Explorer *窗口中,您可以在项目名称旁边看到* Windows Phone 8.1 *或* Windows Phone Silverlight 8.1 *。您的'MainPage'在* WinRT *和* Silverlight *中的'PhoneApplicationPage'中将是'Page的类型。当您选择新项目时,您可以选择*空白应用程序*或*空白应用程序(Silverlight)* - 第二个应位于下面的某个模板中。 – Romasz 2014-10-07 08:14:12