Occurs just before an application shuts down, and cannot be canceled.
Assembly: PresentationFramework (in PresentationFramework.dll)
An application can shut down for either of the following reasons:
The user ends the session by logging off or shutting down.
You can detect when application shutdown occurs by handling theevent, and perform any additional processing as required.
You can also handle Shutdown explicitly. The exit code is exposed from the ApplicationExitCode property of the ExitEventArgs argument that's passed to the event handler. When the application stops running, the exit code is passed to the operating system for subsequent processing.to inspect or change the application exit code when you don't need to call
If your application handles the SessionEnding event and subsequently cancels it, is not raised and the application continues running in accordance with the shutdown mode.
The exit code can be set from an XAML browser application (XBAP), although the value is ignored.
For XBAPs,is raised in the following circumstances:
An XBAP is navigated away from.
In Internet Explorer 7, when the tab that is hosting the XBAP is closed.
When the browser is closed.
In all cases, the value of the ApplicationExitCode property is ignored.
Legacy Code Example
The following example demonstrates how to:
Write an entry to an application log in isolated storage.
Persist the application state to isolated storage.
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0