Share via


Event Handling

CCF uses the Listener design pattern as the basis for its event handling mechanism in the UI. The Listener pattern uses events, event producers, and event listeners to describe the communication flow between components of UI. An event is a message that one object sends to another object. The event producer is the class that sends (or fires) the event, and the event listener (or consumer) is the class that handles the event. In programmatic terms, a method on the event listener object is called when an event that it is listening for is fired.

CCF listeners use the following mechanisms:

  • Event log
  • Error message
  • Message box
  • SqlSink

The base class for all CCF listeners is ListenerConfigurationHandler.cs. This base class defines the configuration settings in the Microsoft.Ccf.Common.Listeners project and provides the configuration section handler for CCF listeners. It implements the IConfigurationSectionHandler interface as required by all configuration section handlers. This interface is extended by applications to define user-defined events. All event objects should extend this class. An event producer or source implements methods that allow event listeners to register and unregister an interest in the event that the event source produces.

The IConfigurationSectionHandler interface has only one method: Create (), which parses the XML node of the configuration section. The actual parsing of the XML is delegated to the ListenerConfigurationLoadValuesFromConfigurationXml method. The returned object is added to the configuration collection and is accessed by the ConfigurationSettings.GetConfig method.