CoreApplication CoreApplication CoreApplication CoreApplication Class


Enables apps to handle state changes, manage windows, and integrate with a variety of UI frameworks.

public : static class CoreApplication
static struct winrt::Windows::ApplicationModel::Core::CoreApplication
public static class CoreApplication
Public Static Class CoreApplication
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


The system creates this object as a singleton when it runs the app. It is run as an Application Single-Threaded Apartment (ASTA). Threads created from the app singleton, such as the view provider (seen in the sample below), should be attributed as Multi-Threaded Apartment (MTAThread).

ref class MyFrameworkViewSource : IFrameworkViewSource
    virtual IFrameworkView^ CreateView()
        return ref new MyFrameworkView();

// ...

int main(Platform::Array<Platform::String^>^)
    auto frameworkViewSource = ref new MyFrameworkViewSource();
    return 0;

Windows Phone 8

This API is supported in native apps only, except for the Properties property, which is always available.


Id Id Id Id

Gets the package-relative app identifier for the process.

MainView MainView MainView MainView

Gets the main CoreApplicationView instance for all running apps that use this CoreApplication instance.

Properties Properties Properties Properties

Gets a property set that the app and UI frameworks can use to store info while the process is running.

Views Views Views Views

Gets all views for the app.


CreateNewView() CreateNewView() CreateNewView() CreateNewView()

Creates a new view for the app.

CreateNewView(String, String) CreateNewView(String, String) CreateNewView(String, String) CreateNewView(String, String)

Creates a new view for the app.

CreateNewView(IFrameworkViewSource) CreateNewView(IFrameworkViewSource) CreateNewView(IFrameworkViewSource) CreateNewView(IFrameworkViewSource)

Creates a new view for the app.

DecrementApplicationUseCount() DecrementApplicationUseCount() DecrementApplicationUseCount() DecrementApplicationUseCount()

Decrements the total count of running app instances that use this CoreApplication instance.

EnablePrelaunch(Boolean) EnablePrelaunch(Boolean) EnablePrelaunch(Boolean) EnablePrelaunch(Boolean)

Enable or disable the operating system's ability to prelaunch your app.

Exit() Exit() Exit() Exit()

Shuts down the app.

GetCurrentView() GetCurrentView() GetCurrentView() GetCurrentView()

Gets the active view for the app.

IncrementApplicationUseCount() IncrementApplicationUseCount() IncrementApplicationUseCount() IncrementApplicationUseCount()

Increments the total count of running app instances that use this CoreApplication instance.

RequestRestartAsync(String) RequestRestartAsync(String) RequestRestartAsync(String) RequestRestartAsync(String)

Restart the app.

RequestRestartForUserAsync(User, String) RequestRestartForUserAsync(User, String) RequestRestartForUserAsync(User, String) RequestRestartForUserAsync(User, String)

Restart the app in the context of a different user.

Run(IFrameworkViewSource) Run(IFrameworkViewSource) Run(IFrameworkViewSource) Run(IFrameworkViewSource)

Runs an external view provider factory to obtain a view provider.

RunWithActivationFactories(IGetActivationFactory) RunWithActivationFactories(IGetActivationFactory) RunWithActivationFactories(IGetActivationFactory) RunWithActivationFactories(IGetActivationFactory)

Runs an activatable type factory to obtain an external activatable type.


BackgroundActivated BackgroundActivated BackgroundActivated BackgroundActivated

Fired when your app is activated by a background trigger.

EnteredBackground EnteredBackground EnteredBackground EnteredBackground

Fired when the app enters the running in the background state.

Exiting Exiting Exiting Exiting

Occurs when the app is shutting down.

LeavingBackground LeavingBackground LeavingBackground LeavingBackground

Fired just before application UI becomes visible.

Resuming Resuming Resuming Resuming

Occurs when an app is resuming.

Suspending Suspending Suspending Suspending

Occurs when the app is suspending.

UnhandledErrorDetected UnhandledErrorDetected UnhandledErrorDetected UnhandledErrorDetected

Occurs when there is an underlying error that is routed to the CoreApplication instance, as part of global error handling logic.

See Also