Megosztás a következőn keresztül:


Application.OnLaunched(LaunchActivatedEventArgs) Method

Definition

Invoked when the application is launched. Override this method to perform application initialization and to display initial content in the associated Window.

protected:
 virtual void OnLaunched(LaunchActivatedEventArgs ^ args) = OnLaunched;
void OnLaunched(LaunchActivatedEventArgs const& args);
protected virtual void OnLaunched(LaunchActivatedEventArgs args);
function onLaunched(args)
Protected Overridable Sub OnLaunched (args As LaunchActivatedEventArgs)

Parameters

args
LaunchActivatedEventArgs

Event data for the event.

Remarks

Override the OnLaunched method to perform any general app initialization that should occur only when the user launches your app normally (for example, by tapping the app tile). For info on other kinds of activation, see OnActivated. Specific activation kinds sometimes have a specific override, also a virtual method on Application. For example, OnFileActivated is invoked for any core Activated event on the Application if the ActivationKind is File.

The starting project templates include a basic implementation for OnLaunched. The implementation sets the initial root visual for the application by setting Window.Current.Content to a new instance of the class defined by the project template's MainPage XAML/code-behind pair. All Application overrides involved in an activation scenario should call Window.Activate in their implementations.

For example code of overrides of OnLaunched, create a new app project and examine the template-created code in the app.xaml code-behind.

Note

The app.xaml code-behind from some project templates reference API in a SuspensionManager helper class. In this case, the OnLaunched override is asynchronous, because some of the SuspensionManager API it calls is asynchronous. For more info, see Minimize startup time.

Applies to

See also