C# 应用程序挂起后恢复相机资源

C# 应用程序挂起后恢复相机资源,c#,windows-phone,windows-phone-8.1,C#,Windows Phone,Windows Phone 8.1,我正在编写一个Windows Phone 8.1(WINPRT-XAML)应用程序 我正在使用MediaCapture API在应用程序中录制视频 上面写着: 您应该在Windows Phone上的挂起事件中清理媒体捕获资源 在Windows Phone上,清理处理程序中的MediaCapture资源 用于挂起应用程序生存期事件,并在 恢复活动 因此,我在App.cs中添加了以下行: public App() { this.InitializeComponent();

我正在编写一个Windows Phone 8.1(WINPRT-XAML)应用程序

我正在使用MediaCapture API在应用程序中录制视频

上面写着:

您应该在Windows Phone上的挂起事件中清理媒体捕获资源

在Windows Phone上,清理处理程序中的MediaCapture资源 用于挂起应用程序生存期事件,并在 恢复活动

因此,我在App.cs中添加了以下行:

 public App()
 {
     this.InitializeComponent();
     this.Suspending += this.OnSuspending;
     this.Resuming += this.App_Resuming;
 }

 void App_Resuming(object sender, object e)
 {
     //TODO: RESUME CAMERA PREVIEW and MediaCapture object here
 }
但是
App\u Resuming
在App从挂起状态恢复到前台状态后不会启动


如何恢复相机资源?

您确定测试正确吗?如果您正在调试应用程序(因此它们无法恢复),应用程序将不会挂起,但您可以从VisualStudio触发生命周期事件

更多信息请点击此处:

关于使用Visual Studio进行调试的注意事项:Visual Studio阻止Windows挂起附加到调试器的应用程序。这允许用户在应用程序运行时查看Visual Studio调试UI。调试应用程序时,可以使用Visual Studio向其发送挂起事件。确保显示调试位置工具栏,然后单击挂起图标


你确定你的测试正确吗?如果您正在调试应用程序(因此它们无法恢复),应用程序将不会挂起,但您可以从VisualStudio触发生命周期事件

更多信息请点击此处:

关于使用Visual Studio进行调试的注意事项:Visual Studio阻止Windows挂起附加到调试器的应用程序。这允许用户在应用程序运行时查看Visual Studio调试UI。调试应用程序时,可以使用Visual Studio向其发送挂起事件。确保显示调试位置工具栏,然后单击挂起图标


天哪…我从来没有想到过。。非常感谢:)它现在起作用了,天哪……我从来没有想到过。。非常感谢:)现在开始工作了
 public App()
 {
     this.InitializeComponent();
     this.Suspending += this.OnSuspending;
     this.Resuming += this.App_Resuming;
 }

 void App_Resuming(object sender, object e)
 {
     //TODO: RESUME CAMERA PREVIEW and MediaCapture object here
 }