Registering a Consumer for an Event

[This is preliminary documentation and subject to change.]

If you followed the previously described examples, you created permanent consumers. To register to receive an event notification, permanent consumers must create at least one of each of the following instances:

The examples create the first two of these, as well as timers that will demonstrate that functionality. This section describes the third item, which is binding particular consumers and filters together.

    To display the example consumers and filters
  1. Select Consumers in the drop-down list box.
  2. Expand the whole inheritance tree.
  3. Click on one of the example consumer instances.

The Event Registration screen now looks like this:

    To register the ServiceStopped consumer for an event
  1. In the left pane, click on the ServiceStopped consumer.
  2. In the right pane, click on the ServiceStoppedEvent filter.
  3. Click the Register button.

The Event Registration screen now looks like this:

Note  The name of the Register button now changes to Unregister. Click it to unregister the selected consumer and filter.

    To test the ServiceStopped consumer-filter binding
  1. In Control Panel, open the Services program.
  2. Find a running service that can be safely stopped.

    —or—

  3. Find an unstarted service and start it.
  4. Stop the service.

    The Event Viewer appears, notifying you of the event:

As shown in the Event Viewer, this event is an instance of __InstanceModificationEvent.

The query in the ServiceStoppedEvent filter uses no timers. The two other example filters do.

    To register the TimerEvent consumer for an absolute event

Absolute events occur only once, at a particular date and time.

  1. From the drop-down list box, choose Timers.
  2. Expand the inheritance tree under __AbsoluteTimerInstruction, then click AbsTimer to open the Edit Instance Properties dialog box.
  3. Click on the Value field of the EventDateTime property to open the Time dialog box.
  4. Set the time to a minute or two in the future, and click OK.
  5. From the drop-down list box, choose Consumers.
  6. In the left pane, expand the consumer inheritance tree and click on the TimerEvent consumer.
  7. In the right pane, click on AbsTimerFilter.
  8. Click the Register button.

    When you reach the set time, the Event Viewer appears, showing the timer event generated at the set time:

    To register the TimerEvent consumer for an interval event

Interval events occur at regularly occurring intervals.

  1. From the drop-down list box, choose Consumers.
  2. In the left pane, expand the consumer inheritance tree, and click on the TimerEvent consumer.
  3. In the right pane, click on IntervalTimerFilter.
  4. Click the Register button.

    The Event Viewer appears, showing the timer event generated every five seconds:

Viewing Class Properties

Creating an Event Consumer Instance

Creating an Event Filter Instance

Creating an Event Timer Instance

See Also

__FilterToConsumerBinding

Binding a Logical Consumer to an Event Filter