CoreApplication class

Applies to Windows and Windows Phone

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

Syntax

Public NotInheritable Class CoreApplication

Attributes

[MarshalingBehavior(Agile)]
[Muse()]
[Version(0x06020000)]
[WebHostHidden()]
[WebHostHidden()]

Members

The CoreApplication class has these types of members:

Events

The CoreApplication class has these events.

EventDescription
Exiting Occurs when the app is shutting down.
Resuming Occurs when an app is resuming.
Suspending Occurs when the app is suspending.
UnhandledErrorDetected Occurs when there is an underlying error that is routed to the CoreApplication instance, as part of global error handling logic.

 

Methods

The CoreApplication class has these methods. It also inherits methods from the Object class.

MethodDescription
CreateNewView Creates a new view for the app.
CreateNewView(String,String) Creates a new view for the app.
DecrementApplicationUseCount Decrements the total count of running app instances that use this CoreApplication instance.
Exit Shuts down the app. Do not use this method to shut down an app outside of testing or debugging scenarios.
GetCurrentView Gets the active view for the app.
IncrementApplicationUseCount Increments the total count of running app instances that use this CoreApplication instance.
Run Runs an external view provider factory to obtain a view provider.
RunWithActivationFactories Runs an activatable type factory to obtain an external activatable type.

 

Properties

The CoreApplication class has these properties.

PropertyAccess typeDescription

Id

Read-onlyGets the package-relative app identifier (PRAID) for the process.

MainView

Read-onlyGets the main CoreApplicationView instance for all running apps that use this CoreApplication instance.

Properties

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

Views

Read-onlyGets all views for the app.

 

Remarks

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
{
public:
    virtual IFrameworkView^ CreateView()
    {
        return ref new MyFrameworkView();
    }
};

// ...

[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^)
{
    auto frameworkViewSource = ref new MyFrameworkViewSource();
    Windows::ApplicationModel::Core::CoreApplication::Run(frameworkViewSource);
    return 0;
}

Windows Phone 8

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

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.Core
Windows::ApplicationModel::Core [C++]

Metadata

Windows.winmd

See also

DirectX swap chain implementation sample
CoreApplicationView

 

 

Show:
© 2014 Microsoft. All rights reserved.