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
Windows 10 requirements
Windows 10, version 1803 (introduced in 10.0.17134.0)
Windows.Foundation.UniversalApiContract (introduced in v6.0)
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.
Whether the current instance of the app is the registered instance of the app for the specific key that this instance has defined.
The key for the current instance.
A shell can recommend an instance of an app to which an application activation is redirected.
Registers an app instance with the platform, or finds an existing instance if another instance has already registered this key.
Gets the current IActivatedEventArgs, the same as would normally be passed in to the OnActivated method of the app.
Gets the registered instances of the current app.
Redirects activation of the current app instance to the specified instance.
Updates the system cache so that the current instance is no longer available for activation redirection.