Delen via


AppInstance.RedirectActivationTo Method

Definition

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

public:
 virtual void RedirectActivationTo() = RedirectActivationTo;
void RedirectActivationTo();
public void RedirectActivationTo();
function redirectActivationTo()
Public Sub RedirectActivationTo ()

Examples

This example redirects activation to the instance recommended by the shell. The example first checks whether there is a recommended instance and whether it is suitable. If the shell does not have preference, the app can look for an existing app instance to redirect to or attempt to register itself as the target.

AppInstance RecommendedInstance = AppInstance.RecommendedInstance;
if ((RecommendedInstance != null) && SelectedKeyIncludesMyKey(RecommendedInstance.Key))
{
    RecommendedInstance.RedirectActivationTo();
}
else
{
    // Look for existing instance or attempt to register itself as target.
}

Remarks

Redirection is a terminal operation. After redirecting, the app can call only CoreApplication.Exit. After the redirection, the app is closed.

An app indicates whether it supports multiple instances in its manifest. The splash screen is not shown until the app decides whether to redirect during main. If the app fails to decide within a time-out period, it is closed.

There is a potential race condition if an app identifies an instance for redirection, but that instance dies before it can be activated. In this case, this activation fails.

Applies to

See also