Thursday, December 18, 2014

Application Life Cycle

  • Application is launched until it is deactivated.

  • Only one application run at a time in windows phone, This model execution is designed for provide a faster, responsive any time.

  • This way to prevent the device from being slow or unresponsive due to running background application.

Terminologies for Application State:


Tombstoning :
  • Operating System deactivates the application process or use exits application.

  • Operating System preserves any information about application’s state.

  • When the application is re-launched, operating system restarts the process and sends the last known state from the application

Page State:
  • Page State completely related to application page.

  • It’s includes scroll positions or text fields content.

  • We can modify page state is done by overriding OnNavigatedTo or OnNavigatedFrom methods.


Application State:
  • It’s maintained state of application.
  • we can modified Application State using PhoneApplicationService class

Persistent (Preserved) Data:
  • Persistent Data is stored and retrieved from Isolated Storage.

Transient (Temporary) State:
  • Transient Data is stored in State Dictionary provided by PhoneApplicationService.
  • When application reactivated, Tombstoned state will be return to Transient State.


Windows Phone Application Lifecycle



Which Events are fired in Application Lifecycle ?

Four events are fired in application lifecycle process.
  • Launching
  • Deactivated
  • Activated
  • Closing


  • Launching:
    • When:
      • when new instance created of application, at the time Launching event is raised.
    • Process:
      • Run application from installed application list or from Tiles in start screen.
    • Advice
      • In Launching event, should not retrieve any data from Isolated Storage, because application will be slow down.
      • Only create instance for application
  • Deactivated:
    • When:
      • When running application is closed by another application, it will be deactivated.
      • When pressing the START button.
      • Due to timeout when main screen locked.
      • Application can also be deactivated by invocation of a Launcher or Chooser or taking picture or sending emails.
    • Do:
      • Application should stored information regarding the current state using State property on PhoneApplicationService
      • No guarantee that application Tombstoned condition will be reactivated, so application data should stored into Isolated.
    • Advice:
      • The whole action has to be finished within 10 sec, Otherwise operating system will not terminate the application, then application failed Certification.
  • Activated:
    • When:
      • Application will be activated from Tombstoned condition.
    • Do:
      • Application should load data from PhoneApplicationService.
    • Advice
      • Similar to Launching event, application should not access resources from network or isolated storage to avoid the process down.
  • Closing:
    • When:
      • When user press back button from application’s initial page
    • Do:
      • Application has to store persistent data into Isolated Storage.
    • Advice
      • No need to store transient data.





No comments:

Post a Comment