Today in this Video tutorial, we will learn about the Lifecycle of Windows 8 Metro style application. We will also learn what are the various states available during the Lifecycle.
Let’s start discussion followed by the video tutorial. An easy way of representation has been added in the video. Let me know your feedback. Don’t forget to share this to your friends and ask their feedback too.
Here is the list of the previous chapters of the video tutorial series. If you didn’t watch them earlier, go thru them before starting with the Windows 8 Metro style application development:
- How to Create a Windows 8 Metro Style Application using Visual Studio 2011?
- What is Package.appxmanifest File in Windows 8 Metro Style Application?
- What is the Lifecycle of Windows 8 Metro Style Application?
Your feedbacks are always welcome. Don’t hesitate to leave a small line here. This will encourage me to publish more tutorials for you.
Application Lifecycle of Metro Style Apps
When you start an application from the storage device, it activates and comes to the running state. When you launch another application, the system pushes the first application to the background and waits for few seconds to see whether the user intends to immediately switch back to that application. After that time interval, the background application moves to Suspended state. During the transition process, the developer can store all unsaved information to the disk.
When the user launches another application, the already running application enters into the background and pushes to the suspended state as mentioned above. The similar process goes on until the system encounters low memory. This ensures that the user can quickly load the suspended application from the memory.
When the system notices a low memory while launching an application, it quickly checks for the unused application which was in suspended mode for long time. It terminates that application first and launches the new application in the foreground.
If the user wants to resume a suspended application, during that time, the running application moves to the suspended state and that app moves out from the suspension to the running state.
Video Tutorial: Lifecycle of Windows 8 Metro Style Application
Here is the complete video tutorial where I discussed about the Lifecycle of Windows 8 Metro style application with a small demonstration:
Hope this will be helpful for you to understand the Lifecycle.
When the process is not running and the user activates that process, the application comes to Launch state. This could be either because the application was never launched or it was suspended but removed from the memory. When an application is launched directly from the storage device, it displays a splash screen to the user. During that time, it completes all main tasks of the application to load it completely. Once all the primary tasks are done, it closes the Splash screen and activates the application main UI.
When an user moves an application to the background or the device enters to the low power state, the application suspends itself. While pushing the application to the background, the system waits for few seconds to make sure that the user doesn’t want to switch back to the application immediately. After that few seconds time interval, the system automatically moves the application to the suspended state. During the transition, you may want to store the unsaved data to the storage device.
Based on your available memory, the system wants to keep a no. of suspended apps into the memory to make sure that, the user can quickly switch back to the application. As I mentioned above, you can’t close an application directly. The metro app always resides in memory as long as your system has available memory to execute. If your available memory is low, the system automatically removes the unused application from memory.
Remember that, the system never fires notification during termination and hence you have to handle your unsaved data during the Suspend state itself.
You can resume a suspended application from memory and bring it to the foreground thread. During the state transition, it loads the application data if you already saved during the suspension state.
Hope, it was a helpful tutorial for you to understand the “Lifecycle of Windows 8 Metro Style Application”. Stay tuned to my blog for more video tutorials on the same topic.
Follow me on Facebook to be updated on latest article news. I am also available on Twitter. Connect with me if you want to contact and/or stay tuned on latest updates. If you have any queries or feedback on this topic, don’t forget to share it here and I will try to help you at the earliest.