इसके माध्यम से साझा किया गया


AppInstance.FindOrRegisterInstanceForKey(String) Method

Definition

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

public:
 static AppInstance ^ FindOrRegisterInstanceForKey(Platform::String ^ key);
 static AppInstance FindOrRegisterInstanceForKey(winrt::hstring const& key);
public static AppInstance FindOrRegisterInstanceForKey(string key);
function findOrRegisterInstanceForKey(key)
Public Shared Function FindOrRegisterInstanceForKey (key As String) As AppInstance

Parameters

key
String

Platform::String

winrt::hstring

A non-empty string as a key for the instance.

Returns

An app instance that represents the first app that registered the key. The caller can determine whether that instance is the current instance.

Examples

This example returns the instance registered for the specified key. If there was no existing app instance for that key, the method registers the current instance, and returns that instance.

theInstance = AppInstance.FindOrRegisterInstanceForKey(key);

Remarks

After an app has registered with the platform, it is returned when other instances query for app instances.

An app instance can register multiple times with different keys. The system cache maintains one row per instance, therefore, the key is overwritten.

Applies to