Share via


WorkspaceBrokerAx.OnWorkspaceSetupCompleted event

[OnWorkspaceSetupCompleted is no longer available for use as of Windows 10 and Windows Server 2016 Technical Preview.]

This event is fired when the SetupWorkspace method is complete. When this event is fired and Result is S_OK, it is safe to use the other WorkspaceBrokerAx methods and properties, such as WorkspacesCount.

Syntax

function handler(statusCode) { /* Your code */ }
 
// attachEvent syntax
workspaceBrokerAx.attachEvent("onworkspacesetupcompleted", handler);
workspaceBrokerAx.detachEvent("onworkspacesetupcompleted", handler);

Event handler parameters

  • statusCode [in]
    Type: Number

    Contains S_OK if no errors occurred, or an HRESULT error code if an error was encountered.

Examples

The following code example, from the RemoteApp and Desktop Connections workspace API sample, shows an example implementation of the OnWorkspaceSetupCompleted event.

function onWorkspaceSetupCompletedHandler(statusCode) {
    WinJS.log && WinJS.log("Workspace subscription succeeded, or a subscribed workspace was modified. Status code: " + statusCode, "sample", "status");
    // This tells you it is now time to update your list of workspaces, workspace folders, and workspace items (see the other scenario in this sample for details)
}

The following code example, from the RemoteApp and Desktop Connections workspace API sample, demonstrates how to add an event listener for the OnWorkspaceSetupCompleted event.

// Initialize the ActiveX control
try {
    wkspActiveX = Microsoft.Sample.WorkspaceBrokerApi.WorkspaceActiveX.createInstance();
} catch (e) {
    WinJS.log && WinJS.log("Error setting up the Workspace ActiveX control. Error: " + e.number + " " + e.description, "sample", "error");
    return;
}

try {
    wkspActiveX.InitializeWorkspaceConfiguration();
} catch (e) {
    if (e.number === -2147024894) {
        // This is equivalent to 0x80070002 (ERROR_FILE_NOT_FOUND), and is expected if you have never been subscribed to any workspaces on this machine
    } else {
        WinJS.log && WinJS.log("Error calling InitializeWorkspaceConfiguration: " + e.number + " " + e.description, "sample", "error");
        return;
    }
}

// Register for workspace subsciption results
wkspActiveX.attachEvent("OnWorkspaceSetupCompleted", onWorkspaceSetupCompletedHandler);

WinJS.log && WinJS.log("Workspace ActiveX control ready", "sample", "status");

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

End of client support

Windows 8.1

End of server support

Windows Server 2012 R2

IDL

Wkspbkax.idl

See also

WorkspaceBrokerAx