This method evaluates the expression asynchronously.

int EvaluateAsync(
   enum_EVALFLAGS       dwFlags, 
   IDebugEventCallback2 pExprCallback


[in] A combination of flags from the EVALFLAGS enumeration that control expression evaluation.


[in] This parameter is always a null value.

If successful, returns S_OK; otherwise returns an error code. A typical error code is:




Another expression is currently being evaluated, and simultaneous expression evaluation is not supported.

This method should return immediately after it has started the expression evaluation. When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2 must be sent to the IDebugEventCallback2 event callback as supplied through IDebugProgram2::Attach or IDebugEngine2::Attach.

The following example shows how to implement this method for a simple CExpression object that implements the IDebugExpression2 interface.

HRESULT CExpression::EvaluateAsync(EVALFLAGS dwFlags,
                                   IDebugEventCallback2* pExprCallback)
    // Set the aborted state to FALSE
    // in case the user tries to redo the evaluation after aborting.
    m_bAborted = FALSE;
    // Post the WM_EVAL_EXPR message in the message queue of the current thread.
    // This starts the expression evaluation on a background thread.
    PostThreadMessage(GetCurrentThreadId(), WM_EVAL_EXPR, 0, (LPARAM) this);
    return S_OK;

Community Additions