Bewerken

Share via


Writing an Event Consumer Provider

An event consumer provider is a component of the permanent consumer architecture that determines which permanent event consumer handles a given event. You should create an event consumer provider along with your permanent event consumers to route events properly from WMI.

An event consumer provider links an event provider with a list of consumer classes. Instances of these consumer classes then receive events from that provider. WMI identifies which consumer provider the events are delivered to, based on the __EventConsumerProviderRegistration instance, which associates the consumer provider __Win32Provider instance with a logical consumer class. Users create instances of the consumer class as part of a permanent subscription. If the event provider is not running when an event occurs, then WMI starts the provider when it needs to deliver events.

The following procedure describes how to implement an event consumer provider.

To implement an event consumer provider

  1. Design consumer classes in Managed Object Format (MOF) and register them with WMI. For more information, see Designing Managed Object Format (MOF) Classes.

    Class providers register with WMI by creating a __Win32Provider instance and an __EventConsumerProviderRegistration class. For more information, see Registering an Event Consumer Provider.

  2. Implement the IWbemProviderInit interface for your provider.

    WMI uses IWbemProviderInit to load and initialize a provider. For more information, see Initializing a Provider.

    Note

    Event consumer providers are strongly encouraged to use the multithreading model "Both".

     

  3. Implement the IWbemEventConsumerProvider interface for your provider.

    The IWbemEventConsumerProvider interface is the primary interface for an event consumer provider.

  4. Supply one or more physical consumers to receive the event messages from WMI.

    A physical consumer is a COM object that represents a permanent event consumer. All physical consumers must implement the IWbemUnboundObjectSink interface. For more information, see Implementing a Physical Consumer.