locked
How to quit from metro style app?

    Question

  • i see some topics that say we need not  close the app, then how about the resources' management  in my app?  they need not  be freeed? and  how can i get the event when my app is hided?   

    thanks a lot

    Wednesday, February 8, 2012 11:23 AM

Answers

  • Hello William,

    When you create a new DirectX Project in Visual Studio 11, you can see the VS generated some code for you. In the application source file you can see an event handler called "OnSuspending".

    In order to get the time to free all the resources you can ask for a deferral, please read the comment in the generated code. You need to free all the resources here, and then restore them in the event "OnResuming".

    The reason you need to free the resources when suspending is that if the application on the foreground needs more memory, your application will be terminated without any notification.

    Please watch "Introduction to DirectX for Metro style apps": http://channel9.msdn.com/events/BUILD/BUILD2011/PLAT-766T for more information

    Hope this helps.

    Thank You,

    - Joseph

    Wednesday, February 8, 2012 1:45 PM
  • Hi William,

    In addition to Joseph's links, see the Application lifecycle docs. Also consider if your resources need to be freed or not. Unless a resource affects other processes there is generally no need to free it when the app is suspended or killed: strictly process local resources (such as memory) go away automatically with the process. In general you should save any state necessary to restore the app to its current position when suspending so that it can be restored cleanly, but you wouldn't want to tear down any internal state so the app can continue if it is resumed without being killed.

    --Rob


    Thursday, February 9, 2012 5:15 AM
    Owner

All replies

  • Hello William,

    When you create a new DirectX Project in Visual Studio 11, you can see the VS generated some code for you. In the application source file you can see an event handler called "OnSuspending".

    In order to get the time to free all the resources you can ask for a deferral, please read the comment in the generated code. You need to free all the resources here, and then restore them in the event "OnResuming".

    The reason you need to free the resources when suspending is that if the application on the foreground needs more memory, your application will be terminated without any notification.

    Please watch "Introduction to DirectX for Metro style apps": http://channel9.msdn.com/events/BUILD/BUILD2011/PLAT-766T for more information

    Hope this helps.

    Thank You,

    - Joseph

    Wednesday, February 8, 2012 1:45 PM
  • Hi William,

    In addition to Joseph's links, see the Application lifecycle docs. Also consider if your resources need to be freed or not. Unless a resource affects other processes there is generally no need to free it when the app is suspended or killed: strictly process local resources (such as memory) go away automatically with the process. In general you should save any state necessary to restore the app to its current position when suspending so that it can be restored cleanly, but you wouldn't want to tear down any internal state so the app can continue if it is resumed without being killed.

    --Rob


    Thursday, February 9, 2012 5:15 AM
    Owner