共用方式為


RemoteSystemSession.CreateWatcher 方法

定義

初始化並傳回 RemoteSystemSessionWatcher 物件,以監視遠端會話是否存在。

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

傳回

要用於探索遠端會話的監看員物件。

Windows 需求

應用程式功能
remoteSystem

範例

如需探索遠端會話的程式,請參閱下列程式碼範例。

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

適用於