Share via


RemoteSystemSession.CreateWatcher Methode

Definition

Initialisiert und gibt ein RemoteSystemSessionWatcher-Objekt zurück, um das Vorhandensein von Remotesitzungen zu überwachen.

public:
 static RemoteSystemSessionWatcher ^ CreateWatcher();
 static RemoteSystemSessionWatcher CreateWatcher();
public static RemoteSystemSessionWatcher CreateWatcher();
function createWatcher()
Public Shared Function CreateWatcher () As RemoteSystemSessionWatcher

Gibt zurück

Ein Watcher-Objekt, das zum Ermitteln von Remotesitzungen verwendet werden soll.

Windows-Anforderungen

App-Funktionen
remoteSystem

Beispiele

Im folgenden Codebeispiel erfahren Sie, wie Sie eine Remotesitzung ermitteln.

// Discover an existing shared experience.
public void DiscoverExistingSessions() {

    // create a watcher for remote system sessions
    RemoteSystemSessionWatcher sessionWatcher = RemoteSystemSession.CreateWatcher();

    // register a handler for the "added" event
    sessionWatcher.Added += async (sender, args) => {

        // get a reference to the info about the discovered session
        RemoteSystemSessionInfo sessionInfo = args.RemoteSystemSessionInfo;

        // update the UI with the sessionInfo.DisplayName and 
        // sessionInfo.ControllerDisplayName strings. Save a reference to 
        // this RemoteSystemSessionInfo, to use when the user selects
        // this session from the UI

        //...
    };

    // Begin watching
    sessionWatcher.Start();
}

Gilt für: