A messaging system is basically a mechanism to notify some observers about the firing of some event. The event may have some attached information that we call message content but the notification of the event is the crucial point of the whole thing.
We have seen so far how messages are defined and sent through the message manager. Now it is time to learn how to subscribe for notifications. Multiple observers may register themselves to be notified when the event occurs (that is, a matching message passes through the message manager).
The TMessageManager class offers a SubscribeToMessage method you can use to provide an event handler (once again, with two main options, that is, implementing the handler through an anonymous method, or using a standard method reference).
The following snippet shows how to subscribe for the TEventX message we have used in previous paragraphs:
TMessageManager.DefaultManager.SubscribeToMessage(
TEventX
, procedure...