IWbemObjectSink interface (wbemcli.h)
The IWbemObjectSink interface creates a sink interface that can receive all types of notifications within the WMI programming model. Clients must implement this interface to receive both the results of the asynchronous methods of IWbemServices, and specific types of event notifications. Providers use, but do not implement this interface to provide events and objects to WMI.
Typically, providers call an implementation provided to them by WMI. In these cases, call Indicate to provide objects to the WMI service. After that, call SetStatus to indicate the end of the notification sequence. You can also call SetStatus to indicate errors when the sink does not have any objects.
When programming asynchronous clients of WMI, the user provides the implementation. WMI calls the methods to deliver objects and set the status of the result.
The IWbemObjectSink interface inherits from the IUnknown interface. IWbemObjectSink also has these types of members:
The IWbemObjectSink interface has these methods.
Called by a source to provide a notification.
Called by sources to indicate the end of a notification sequence, or to send other status codes to the sink.
When implementing an event subscription sink (IWbemObjectSink or IWbemEventSink), do not call into WMI from within the Indicate or SetStatus methods on the sink object. For example, calling IWbemServices::CancelAsyncCall to cancel the sink from within an implementation of Indicate can interfere with the WMI state. To cancel an event subscription, set a flag and call IWbemServices::CancelAsyncCall from another thread or object. For implementations that are not related to an event sink, such as object, enum, and query retrievals, you can call back into WMI.
Sink implementations should process the event notification within 100 MSEC because the WMI thread that delivers the event notification cannot do other work until the sink object has completed processing. If the notification requires a large amount of processing, the sink can use an internal queue for another thread to handle the processing.
The following code example is a simple implementation of an object sink. This sample can be used with IWbemServices::ExecQueryAsync or IWbemServices::CreateInstanceEnumAsync to receive the returned instances:
|Minimum supported client||Windows Vista|
|Minimum supported server||Windows Server 2008|
|Header||wbemcli.h (include Wbemidl.h)|