Freigeben über


IApplicationLifetimeAware Interface

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Interface IApplicationLifetimeAware
public interface IApplicationLifetimeAware

The IApplicationLifetimeAware type exposes the following members.

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Exited Called by an application immediately after the Application.Exit event occurs.
Public methodSupported by Silverlight for Windows Phone Exiting Called by an application immediately before the Application.Exit event occurs.
Public methodSupported by Silverlight for Windows Phone Started Called by an application immediately after the Application.Startup event occurs.
Public methodSupported by Silverlight for Windows Phone Starting Called by an application immediately before the Application.Startup event occurs.

Top

Remarks

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.

For more information, see Application Extension Services.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.