Debug.msTraceAsyncOperationStarting Function

Initiates a trace for an asynchronous operation.

Syntax

Debug.msTraceAsyncOperationStarting(operationName)  

Parameters

operationName
Required. A string that identifies the asynchronous operation. If operationName is null or undefined, an empty string is used for the operation name.

Return Value

An integer representing the operation ID.

Remarks

Call this method before the asynchronous operation starts.

Note

Some debugging tools do not display the information sent to the debugger.

Example

The following code provides an example of instrumenting an asynchronous call for a Windows 8.x 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();  

Requirements

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.