Before reading this article, please go through the following articles:
- Background Task in Universal Windows Program - Part One
- Background Task in Universal Windows Program - Part Two
- Background Task in Universal Windows Program - Part Three
Introduction
In Windows 10, the background task is hosted into a separate process. That means, the main application runs in different processes, while the background task runs in the separate process.
Windows 10 Anniversary Update (Version 1607 ) includes one more feature in the background process. Background process is now included into the application process, and this single process handles them both, the application(GUI) and the background task.
Application life cycle
Application life cycle process has had several major changes to implement the single process concept.

Initially, the application is not running. App object enters the Background Task activity and Background Task has stopped when application is running. To implement this concept, Application object has two events to be implemented:
- Application. Current. EnteredBackground
- Application. Current. LeavingBackground
These events play a major role in handling the Background task (In older versions of the Windows, Runtime Component handles all this stuff).
Sample Code
- Application.Current.EnteredBackground += app_EnteredBackground;
- Application.Current.LeavingBackground += app_LeavingBackground;
Application is into the non-running mode. This event gets triggered and the background task starts here. The application process enters the background activities and application reaches the suspended state forever. This is the best place to store the application session state.
- private void app_LeavingBackground(object sender, LeavingBackgroundEventArgs e)
- {
- }

Application. Current. LeavingBackground
Application enters the Visible mode. This event gets triggered, application process exits into the background activities and handles the UI based functionality, this is best place to handle the activated application or resume events functionality here.
- private void app_EnteredBackground(object sender, EnteredBackgroundEventArgs e) {
- }



Ramesh PalaniappanPosted Aug 10, 2016, 10:20 AM
Nice Article.
Vignesh ManiPosted Aug 10, 2016, 8:34 AM
Nice