为了账号安全,请及时绑定邮箱和手机立即绑定

使用WinRT不引发挂起事件

使用WinRT不引发挂起事件

一只甜甜圈 2019-07-11 10:40:26
使用WinRT不引发挂起事件我在WindowsPhone 8.1上使用WinRT挂起事件有问题,它不会触发。我也不知道原因。这是我的密码:/// <summary>/// Initializes the singleton application object. This is the first line of authored code/// executed, and as such is the logical equivalent of main() or WinMain()./// </summary>public App(){    InitializeComponent();    Suspending += OnSuspending;#if DEBUG    this.displayRequest = new DisplayRequest();#endif}/// <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){    var deferral = e.SuspendingOperation.GetDeferral();    deferral.Complete();}我在线路上设置了一个断点var deferral = e.SuspendingOperation.GetDeferral();并使用VisualStudio对其进行了调试。然后我按下手机上的“开始”按钮,运行另一个应用程序,等待大约10秒。OnSuspending不是逃跑。有什么想法吗?
查看完整描述

3 回答

?
慕丝7291255

TA贡献1859条经验 获得超6个赞

我不知道你为什么要我给你看证据链接-不难找到MSDN博客->“如何调试流程生命周期事件”,它说:如果您想通过在每个处理程序中设置一个断点并按F5在VisualStudio中启动调试器来调试前面部分的代码,那么即使应用程序来回切换到屏幕上,您也将永远等待它们触发!原因很简单:在调试应用程序时,Windows不会将其挂起。

查看完整回答
反对 回复 2019-07-11
?
月关宝盒

TA贡献1772条经验 获得超5个赞

我花了好几个小时才找到这个金块。TBF我并不知道我在寻找什么-我的症状(我在谷歌上搜索)是“Windows Phone应用程序崩溃,但不是在调试模式下调试”-也许留下这条评论将帮助Google链接到其他搜索同样事情的人这个很好的答案。这个答案不能解决问题,但它可以帮助您识别问题。 

查看完整回答
反对 回复 2019-07-11
  • 3 回答
  • 0 关注
  • 581 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信