Events

COM events support a N:M publish/subscribe model. A connection point (source) can have multiple subscribers (1:M) and a listener (sink) can subscribe to multiple COM servers (N:1).

The protocol to subscribe to an event is formal and has several steps.

  1. It is assumed that a user-defined callback interface has been registered on the system. The sink implements this interface.
  2. The sink calls QueryInterface on the source to get a pointer to IConnectionPointContainer.
  3. The sink calls IConnectionPointContainer::FindConnectionPoint with the IID of the callback interface, and gets a pointer to the relevant IConnectionPoint.
  4. The sink calls IConnectionPoint::Advise to start receiving events.
  5. (The source sends events to the sink’s callback interface…)
  6. To unsubscribe, the sink calls IConnectionPoint::Unadvise and calls Release on the IConnectionPoint and IConnectionPointContainer pointers.

.NET components can be both sources and sinks of COM events (a.k.a. unmanaged events).


References