Share via


AppInstance.RecommendedInstance 屬性

定義

殼層可以建議應用程式啟用重新導向的應用程式實例。

public:
 static property AppInstance ^ RecommendedInstance { AppInstance ^ get(); };
static AppInstance RecommendedInstance();
public static AppInstance RecommendedInstance { get; }
var appInstance = AppInstance.recommendedInstance;
Public Shared ReadOnly Property RecommendedInstance As AppInstance

屬性值

殼層偏好用於應用程式的應用程式實例,如果沒有 null 喜好設定,則為 。

範例

此範例會使用應用程式定義的 SelectedKeyIncludesMyKey 方法,檢查殼層是否建議實例。 如果是,它會檢查實例是否適合,並重新導向至適當的實例。 如果殼層沒有喜好設定,應用程式可以尋找現有的應用程式實例,以重新導向或嘗試將本身註冊為目標。

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

備註

如果殼層提供喜好設定,應用程式可以將啟用重新導向至該實例。 應用程式可以忽略喜好設定。

注意

目前,殼層不會為 RecommendedInstance設定非 Null 值。

適用於