当我再次点击我的应用程序时获得回调方法 - Windows应用商店应用

时间:2015-09-02 10:10:23

标签: c# windows-store-apps

我做了以下事情: 1.推出我的应用程序 2.推出另一个应用程序 3.再次点击我的应用程序(例如从应用程序列表中取出)

在步骤.3我希望得到一个消息回调,但我不会。

在App.xaml.cs文件中,我添加了方法onResuming this

的方法:

public App()
{
        //this.askToBeOnLockScreen();
        this.createRegisterBgTask();

        this.InitializeComponent();

        this.Suspending += OnSuspending;
        this.Resuming += OnResuming;
    }

这里我重写了两种方法:

    private void OnResuming(object sender, object e)
    {
        Debug.WriteLine("OnResuming ...................");
    }





    private void OnSuspending(object sender, SuspendingEventArgs e)
    {
        Debug.WriteLine("onsuspending ......................................................");
        var deferral = e.SuspendingOperation.GetDeferral();

        deferral.Complete();
    }

甚至没有调用onsuspending。

我做错了什么?

我是Windows商店应用的新手

1 个答案:

答案 0 :(得分:1)

您可能正在从Visual Studio启动应用程序并触发暂停/恢复,您只需使用应用程序中的最小化按钮。这对于从VS启动并连接了调试器的应用程序不起作用。

要模拟supend / resume,请使用Visual Studio中的lifecyle-events工具栏。它看起来像这样:enter image description here

如果您没有找到它,请不要担心,它会在您开始在Viusal Studio中调试应用后立即显示。

相关问题