GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing learn.microsoft.com — CoreApplication Class (Windows.ApplicationModel.Core) - Windows apps Note Access to this page requires authorization. You can try signing in or changing directories. Access to this page requires authorization. You can try changing directories. Core
|
| Requirements | Description |
|---|---|
| Device family |
Windows 10 (introduced in 10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
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).
This API is supported in Universal Windows Platform apps only, except for the Properties property, which is always available.
struct App : implements<App, IFrameworkViewSource, IFrameworkView>
{
public:
IFrameworkView CreateView()
{
return *this;
}
};
...
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
Windows::ApplicationModel::Core::CoreApplication::Run(App());
}
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;
}
internal class ApplicationSource : IFrameworkViewSource
{
public virtual IFrameworkView CreateView()
{
return new CoreApp();
}
}
...
[MTAThread]
public static int Main()
{
var appSource = new ApplicationSource();
CoreApplication.Run(appSource);
return 0;
}
| Windows version | SDK version | Value added |
|---|---|---|
| 1607 | 14393 | BackgroundActivated |
| 1607 | 14393 | EnablePrelaunch |
| 1607 | 14393 | EnteredBackground |
| 1607 | 14393 | LeavingBackground |
| 1709 | 16299 | RequestRestartAsync |
| 1709 | 16299 | RequestRestartForUserAsync |
| Name | Description |
|---|---|
| Id |
Gets the package-relative app identifier for the process. |
| MainView |
Gets the main CoreApplicationView instance for all running apps that use this CoreApplication instance. |
| Properties |
Gets a property set that the app and UI frameworks can use to store info while the process is running. |
| Views |
Gets all views for the app. |
| Name | Description |
|---|---|
| CreateNewView() |
Creates a new view for the app. |
| CreateNewView(IFrameworkViewSource) |
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. |
| EnablePrelaunch(Boolean) |
Enable or disable the operating system's ability to prelaunch your app. |
| Exit() |
Shuts down the app. |
| GetCurrentView() |
Gets the view corresponding to the current thread. |
| IncrementApplicationUseCount() |
Increments the total count of running app instances that use this CoreApplication instance. |
| RequestRestartAsync(String) |
Restart the app. |
| RequestRestartForUserAsync(User, String) |
Restart the app in the context of a different user. |
| Run(IFrameworkViewSource) |
Runs an external view provider factory to obtain a view provider. |
| RunWithActivationFactories(IGetActivationFactory) |
Runs an activatable type factory to obtain an external activatable type. |
| Name | Description |
|---|---|
| BackgroundActivated |
Fired when your app is activated by a background trigger. |
| EnteredBackground |
Fired when the app enters the running in the background state. |
| Exiting |
Occurs when the app is shutting down. |
| LeavingBackground |
Fired just before application UI becomes visible. |
| 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. |
Was this page helpful?