locked
How to programmatically close an app

    Question

  • Hi, thanks for the feedback.  I have added a "Close the application now" button to the GUI.  What code do I type to close the application properly?  Thanks, Arvi

    Monday, September 1, 2014 11:48 PM

Answers

  • You cannot programmatically close the application properly. The user can use the system-provided close mechanisms and so the app doesn't need to have it own button to do so.

    The app can force an exit by calling the Application.Exit method if it gets into a unexpected state or such, but that will be treated as an app crash by the OS.

    See App close for more information.

    --Rob

    Tuesday, September 2, 2014 5:32 PM
    Owner

All replies

  • You cannot programmatically close the application properly. The user can use the system-provided close mechanisms and so the app doesn't need to have it own button to do so.

    The app can force an exit by calling the Application.Exit method if it gets into a unexpected state or such, but that will be treated as an app crash by the OS.

    See App close for more information.

    --Rob

    Tuesday, September 2, 2014 5:32 PM
    Owner
  • Closing Application is also the part of automatic life cycle of app you cannot close app you can suspend the app but cannot close the phone OS itself identifies when to completely close a app otherwise it goes into suspension mode and in suspension mode app does not consume any cpu resources its a very clever life cycle approach create by microsoft for its users you can send you app into suspension mode but here make sure if you want to save app data please save it before sending it to suspension mode cause when app goes into suspension mode it is closed by OS (dependent on memory needs) without notifying.

    Please read this for further help:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465115.aspx

    Thank you

    Muhammad Asad

     
    Tuesday, September 2, 2014 6:22 PM