WinRT How to check if the application was suspended?

153 Views Asked by At

I have done the LoadState and SaveState and all works fine.

I just want to check in the page's constructor if I came from suspension or not... I can do a global bool variable and when I enter to the LoadState to change it's value:

bool suspended;

protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
    ...

    if (pageState != null)
    {
         suspended = true;
         ...
    }
}

public MainPage()
{
    this.InitializeComponent();

    if (!suspended)
    {
        ...
    }
}

This works fine, but is there something build in? I think I can check it without global variable...

1

There are 1 best solutions below

0
Farhan Ghumra On BEST ANSWER

In App.xaml.cs OnLaunched(LaunchActivatedEventArgs args) event can provide you that details. You just have to pass args while navigating to particular page. args has property called PreviousExecutionState