AppInstance Class

Definition

Represents an instance of an app.

public ref class AppInstance sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 393216)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AppInstance final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 393216)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class AppInstance
Public NotInheritable Class AppInstance
Inheritance
Object Platform::Object IInspectable AppInstance
Attributes

Windows requirements

Device family
Windows 10, version 1803 (introduced in 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v6.0)

Remarks

The system maintains a store of app instances. Apps can use this for redirection of an app when it attempts to activate.

When an app process is created in the Main method of the app, it can choose to continue to activate the current instance, or to redirect the activation to an existing instance.

The shell can provide a preferred instance for redirection. The app is encouraged to redirect to that instance. The choice of whether to redirect remains with the app.

The AppInstance class is intended to be used in the Main method of the app. If this class is used later, the property values may be null, and the methods may fail.

Before any instances can be returned, they must be registered with FindOrRegisterInstanceForKey.

This class can only be used from an app that has opted in to multi-instancing. Specify the SupportsMultipleInstances attribute on the Application element in the package manifest for the app.

Properties

IsCurrentInstance

Whether the current instance of the app is the registered instance of the app for the specific key that this instance has defined.

Key

The key for the current instance.

RecommendedInstance

A shell can recommend an instance of an app to which an application activation is redirected.

Methods

FindOrRegisterInstanceForKey(String)

Registers an app instance with the platform, or finds an existing instance if another instance has already registered this key.

GetActivatedEventArgs()

Gets the current IActivatedEventArgs, the same that would normally be passed in to the OnActivated method of the app.

GetInstances()

Gets the registered instances of the current app.

RedirectActivationTo()

Redirects activation of the current app instance to the specified instance.

Unregister()

Updates the system cache so that the current instance is no longer available for activation redirection.

Applies to

See also