Share via


RemoteSystemSession.CreateWatcher Method

Definition

Initializes and returns a RemoteSystemSessionWatcher object to monitor the presence of remote sessions.

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

Returns

A watcher object to be used in discovering remote sessions.

Windows requirements

App capabilities
remoteSystem

Examples

See the code example below for the process of discovering a remote session.

// 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();
}

Applies to