Debug.msTraceAsyncOperationCompleted Function

Indicates that an asynchronous operation has completed.

Debug.msTraceAsyncOperationCompleted(asyncOperationId, status)

asyncOperationId

Required. The ID associated with an asynchronous operation.

status

Optional. The status of the asynchronous operation. If not specified, Debug.MS_ASYNC_OP_STATUS_SUCCESS is used.

Call this function when the asynchronous operation completes.

asyncOperationId must correspond to the operation ID previously returned from Debug.msTraceAsyncOperationStarting.

The possible values for status include:

  • Debug.MS_ASYNC_OP_STATUS_SUCCESS

  • Debug.MS_ASYNC_OP_STATUS_CANCELED

  • Debug.MS_ASYNC_OP_STATUS_ERROR

Note Note

Some debugging tools, such as F12 developer tools, do not display the information sent to the debugger. Visual Studio supports this function and shows relevant information in the call stack and the Tasks window.

The following code provides an example of tracing an asynchronous call for a Windows Store app.

function asyncWrapperFunction() {
    var opID = Debug.msTraceAsyncOperationStarting('async trace');
    doSomethingAsync().then(function (result) {
        Debug.msTraceAsyncOperationCompleted(opID, Debug.MS_ASYNC_OP_STATUS_SUCCESS);
        Debug.msTraceAsyncCallbackStarting(opID);
        // Process result of async operation.
    }, function (error) {
        Debug.msTraceAsyncOperationCompleted(opID, Debug.MS_ASYNC_OP_STATUS_ERROR);
        Debug.msTraceAsyncCallbackStarting(opID);
    });

    Debug.msTraceAsyncCallbackCompleted();
}

function doSomethingAsync() {
    return WinJS.Promise.as(true);
}

asyncWrapperFunction();

Supported in the Internet Explorer 11 standards document mode. Also supported in Store apps (Windows 8.1 and Windows Phone 8.1). See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Not supported in Windows 8.

Show:
© 2014 Microsoft