locked
how to suspend and resume in the game app

    Question

  • i find some code to suspend:

    // Add handler

    CoreApplication::Suspending += ref new EventHandler<SuspendingEventArgs^>(this, &View::OnSuspending);  

    // implemention

    void View::OnSuspending( 

        _In_ Platform::Object^ sender,  
        _In_ SuspendingEventArgs^ args 
        ) 
    {
    SuspendingOperation^ op = args->SuspendingOperation; 
        SuspendingDeferral^ deferral = op->GetDeferral(); 

        m_renderer->OnSuspending();
        deferral->Complete();
    }

    ////////////////////////////////////////

    but i cant find the resuming operation code ,  and i find some games show red "suspend" in taskmanager,  but my game shows nothing behind the app name, how can i suspend my game when it is suspended by the system? and when system return back to my game again ,then i can resume it,  thank you

    Friday, February 10, 2012 5:44 AM

Answers

  • Hi William,

    Your app isn't in control of when it suspends and resumes. This will happen automatically. What you have found are notifications that tell your app when Windows has suspended it because the user has moved on to something else. When you receive the the suspend notification you should save out any needed state so that you can resume in the same place you when receive the Activated notification.

    Note that your app won't actually suspend when it is being debugged (otherwise it would suspend when you switched to the debugger and you wouldn't be able to debug it).

    Also see Application lifecycle and Guidelines for managing app lifecycle.

    --Rob

    Friday, February 10, 2012 8:17 PM
    Owner