DIEnumWbemClassObject.NextAsync

[This is preliminary documentation and subject to change.]

When you need a controlled asynchronous retrieval of objects to a sink, use the DIEnumWbemClassObject.NextAsync method. Normal asynchronous retrieval, such as a call to DIWbemServices.ExecQueryAsync, causes an uncontrolled delivery of objects to the caller's implementation of DIWbemObjectSink. This method is helpful in situations where components can only handle a reduced rate of delivery.

NextAsync(
  [in] uCount As Long, 
  [in] pSink As Object
) As Long
 

Parameters

uCount
The number of objects requested.
pSink
DWbemClassObject type object The sink to receive the objects. The caller must implement the sink.

Return Values

WBEM_NO_ERROR The call succeeded. The system begins delivery of objects to the sink.
WBEM_S_FALSE The call failed, and no objects will be delivered to the sink.

Remarks

This call returns immediately, and delivery to the sink occurs in the background. If a call to Reset. it will not affect the ongoing delivery of objects as a result of previous calls but will cause new calls to start at the beginning of the object sequence.

Call the DIWbemobjectSink.SetStatus method to indicate the actual result of your request. As the objects become available, you can call DIWbemObjectSink.Indicate zero or more times to deliver the objects. After that, if uCount items return, call DIWbemObjectSink.SetStatus with a value of WBEM_NO_ERROR.

If fewer objects are available than the number requested, call DIWbemObjectSink.Indicate for whatever objects are available. After that, call DIWbemObjectSink.SetStatus with a value of WBEM_S_FALSE or the error code if there is an error. If no objects are available, do not call Indicate.

Sample Code


Sub ListObjects3(pEnum As DIEnumWbemClassObject , pSink As DIWbemObjectSink) 
    Dim hRes As Long
    Dim bContinue As Boolean

    while (TRUE)
    
        hRes = pEnum.NextAsync(5, pSink)

            ' Wait until sink is ready for more by
            ' some private mechanism. Note that hRes gives
            ' no indication as to whether to continue the
            ' enumeration or not.

            bContinue = WaitUntilMoreObjectsNeeded()

            if  (bContinue <> True) Then
                Exit Sub
            Endif
    Wend
 End Sub