Misha Zaslavsky
Misha Zaslavsky

Reputation: 9646

WinRT How to check if the application was suspended?

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...

Upvotes: 0

Views: 116

Answers (1)

Farhan Ghumra
Farhan Ghumra

Reputation: 15296

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

Upvotes: 1

Related Questions