程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Suspending event not raising using WinRT大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Suspending event not raising using WinRT?

开发过程中遇到Suspending event not raising using WinRT的问题如何解决?下面主要结合日常开发的经验,给出你关于Suspending event not raising using WinRT的解决方法建议,希望对你解决Suspending event not raising using WinRT有所启发或帮助;

Suspending event won’t fire while you are deBUGging (but while running your App normal, it will fire just after you navigate away from the App) as it is saID also at this blog:

Note that this may lead to some weird app behavior, when there is something wrong in Suspending event - for example if you pass some complex class inFrame.Navigate method and you use SuspensionManager. While deBUGging your app will work just fine (no suspension), but will crash without deBUG mode.

To test how your App behaves, you will have to invoke the Suspending manuallt, open (or set visiblE) DeBUG LOCATIOn toolbar in Visual studio, there you will find a dropdown lifecyce events, choose there Suspend, and then to return the App - Resume.

Suspending event not raising using WinRT

解决方法

I’m having a problem with suspending event on Windows Phone 8.1 using WinRT,
it does not fire. I don’t know why. This is my code:

/// <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();
}

I set a breakpoint on the line var deferral = e.SuspendingOperation.GetDeferral(); and debugged it with Visual studio. Then
I pressed the start button on my phone and ran another app and waited about 10
seconds. OnSuspending is not running.

Any ideas?

大佬总结

以上是大佬教程为你收集整理的Suspending event not raising using WinRT全部内容,希望文章能够帮你解决Suspending event not raising using WinRT所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。