Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IApplicationLifetimeAware Interface

May 11, 2014

Defines methods that application extension services can optionally implement in order to respond to application lifetime events.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

public interface IApplicationLifetimeAware

The IApplicationLifetimeAware type exposes the following members.

  NameDescription
Public methodExitedCalled by an application immediately after the Application.Exit event occurs.
Public methodExitingCalled by an application immediately before the Application.Exit event occurs.
Public methodStartedCalled by an application immediately after the Application.Startup event occurs.
Public methodStartingCalled by an application immediately before the Application.Startup event occurs.
Top

You can add extension services to an application using XAML or procedural code with the Application.ApplicationLifetimeObjects property.

Application extension services must implement the IApplicationService interface in order to perform start and stop operations. Additionally, application extension services can implement the optional IApplicationLifetimeAware interface in order to perform operations immediately before and after the Application.Startup and Application.Exit events.

The following list indicates the order in which application lifetime events occur and the IApplicationService and IApplicationLifetimeAware methods are called:

  1. The application calls the IApplicationService.StartService method for each application service.

  2. The application calls the Starting method for each IApplicationLifetimeAware service.

  3. The Application.Startup event occurs.

  4. The application calls the Started method for each IApplicationLifetimeAware service.

  5. The application runs until the stop sequence is initiated by user action. This typically occurs when the user closes the application or browser window, or navigates to a new Web page.

  6. The application calls the Exiting method for each IApplicationLifetimeAware service.

  7. The Application.Exit event occurs.

  8. The application calls the Exited method for each IApplicationLifetimeAware service.

  9. The application calls the IApplicationService.StopService method for each application service.

The application calls each service method one time per service. These methods are called in the order that the services were registered, except that the StopService methods are called in the opposite order. This enables orderly cleanup.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft