Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:08:39+00:00 2026-06-15T05:08:39+00:00

If my app is terminated by Windows (e.g, if it has been suspended, but

  • 0

If my app is terminated by Windows (e.g, if it has been suspended, but then Windows needs to free up memory so it preempts my app), when it is restarted, the OnLaunched() event occurs and I can test whether it was Terminated (or the user simply closed it):

    . . .
        if ((args.PreviousExecutionState == ApplicationExecutionState.Terminated) ||
            (args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser))
        {
        }
    . . .

If terminated, I’d like to resume at the previous location/page, rather than at the initial page (if different). How can I do this? Pseudocode might be:

if (CurrentPage != LastSavedPage)
{
    CurrentPage = LastSavedPage;
    // or: Frame.Navigate(typeof(LastSavedPage)
}

UPDATE

So this is my take on what I should do, but I still “have a doubt about it” (see comment and code following it)

// OnNavigateTo in each page:
Settings.Values["CurrentPageType"] = this.GetType();
Settings.Values["CurrentPageParam"] = args.Parameter; 
//Will the line directly above work even if args.Parameter is empty, or must I do something like:
if (null != args.Parameters)
{
     Settings.Values["CurrentPageParam"] = args.Parameter; 
}

//OnLaunched in app.xaml.cs
                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    if ((localSettings.Values.ContainsKey("CurrentPageType")) &&
                        (localSettings.Values.ContainsKey("CurrentPageParam")))
                    {
                        rootFrame.Navigate((Type)localSettings.Values["CurrentPageType"],
                                                                     localSettings.Values["CurrentPageParam"]);
                    }
                }

UPDATE 2

I get an exception with this code:

    ApplicationData.Current.LocalSettings.Values["CurrentPageType"] = this.GetType();
    ApplicationData.Current.LocalSettings.Values["CurrentPageParam"] = args.Parameter;

An exception of type ‘System.Exception’ occurred in mscorlib.dll but was not handled in user code
WinRT information: Error trying to serialize the value to be written to the application data store
Additional information: Data of this type is not supported.
If there is a handler for this exception, the program may be safely continued.

If I append “.ToString()” to the call to GetType(), it doesn’t blow up…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:08:40+00:00Added an answer on June 15, 2026 at 5:08 am

    Sure! When you override OnNavigatedTo you need to persist two things:

    1) The type of the current class, something like:

    Settings.Values["CurrentPageType"] = this.GetType();
    

    2) The params passed to the current page, something like:

    Settings.Values["CurrentPageParams"] = e.Parameters;
    

    The first caveat is that your parameters must be serializeable. That’s up to you.

    The second consideration is if your applications relies on the backstack for navigation. if so, then you will need to persist more than just the current page’s type, but the breadcrumb behind it. That’s up to you, too.

    Then it’s just something like:

    Frame.Navigate(
        (Type)Settings.Values["CurrentPageType"], 
        Settings.Values["CurrentPageParams"]);
    

    Please check for nulls and stuff like that. But, ion a nutshell, that’s how.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET Compact Framework app that can runs on three windows machines
I recently had an app rejected from the app store because of Low Memory
We have a .NET console app that has many foreground threads. If we kill
Clearly I've been spoiled with Chrome and its developers tools but I'm struggling to
I have an iphone app that has a root view with a button that
In current NSWindowController, add a child window (mainViewController.window),then close current window,BUT when the method
So when I am creating an App Package, the Windows App Certification Kit fails
I built a VB .NET app which has a connection to SQL Server. While
Within my windows app, i'm using a c++ DLL wrapped with a .NET DLLs
The context of my problem is: I have a Windows .NET app (GUI) running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.