![](/img/trans.png)
[英]handle user tapped event on area of screen for windows phone 8.1 app
[英]Event at app shutdown Windows Phone 8.1
我正在使用相机为Windows Phone创建我的第一个应用程序。 在关闭时,我想调用一个dispose方法从MediaCapture object
释放资源。 但是我找不到一个在应用程序关闭时触发的事件。
有谁知道我如何在关机时处置该对象? 现在,当关闭应用程序时,原因导致手机冻结。
在您的app.xaml.cs中,您通常会获得此类
public sealed partial class App : Application
在创建项目时,内部已经有两种有趣的方法
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
}
因此,如您在解释功能的摘要中所读,当用户挂起应用程序时会调用该函数,但是您不知道该应用程序将终止还是稍后恢复,因此我认为您没有办法。
因此,我建议将您的资源放置在OnSuspending函数中
那是针对Windows Phone 8.1和Windows 8.1 Metro风格的应用程序
如果要在WPF项目中执行此操作,实际上
OnExit(ExitEventArgs e)
请参阅此处的Msdn文档(仅适用于WPF)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.