Represents a list of handlers that all implement the IMessageHandler interface. This list can be dynamically updated and each element in the list is passed messages for processing. More...
Public Member Functions | |
void | SendMessage (Message message) |
Send a message to each of the handlers in the list, protected by a multi-threading lock. | |
void | AddHandler (IMessageHandler window) |
Add an instance of the IMessageHandler interface to end of the list of handlers, protected by a multi-threading lock. | |
void | RemoveHandler (IMessageHandler window) |
Remove an instance of the IMessageHandler interface from the list, protected by a multi-threading lock. | |
override string | ToString () |
Convert this HandlerChain to a string, protected by a multi-threading lock. | |
Private Attributes | |
List< IMessageHandler > | _messageHandlers = new List<IMessageHandler>() |
The list of message handlers. | |
object | _messageHandlersLock = new object() |
Object used to lock access to the message handlers list for multi-threaded support. | |
Represents a list of handlers that all implement the IMessageHandler interface. This list can be dynamically updated and each element in the list is passed messages for processing.
Definition at line 55 of file HandlerChain_Class.cs.
|
inline |
Add an instance of the IMessageHandler interface to end of the list of handlers, protected by a multi-threading lock.
If a message handler is already in the list, it is not added again.
window | The IMessageHandler object to add. |
Definition at line 103 of file HandlerChain_Class.cs.
References HandlerChain._messageHandlers, HandlerChain._messageHandlersLock, and IMessageHandler.ID.
Referenced by MessageWindow.CreateWindow().
|
inline |
Remove an instance of the IMessageHandler interface from the list, protected by a multi-threading lock.
If the message handler is not in the list, the request to remove is ignored.
window |
Definition at line 124 of file HandlerChain_Class.cs.
References HandlerChain._messageHandlers, HandlerChain._messageHandlersLock, and IMessageHandler.ID.
Referenced by MessageWindow._HandleCloseMessage().
|
inline |
Send a message to each of the handlers in the list, protected by a multi-threading lock.
message | The Message object to send to each handler. |
Definition at line 74 of file HandlerChain_Class.cs.
References HandlerChain._messageHandlers, HandlerChain._messageHandlersLock, and IMessageHandler.ProcessMessage().
Referenced by MessageWindow._HandleButtonUpMessage(), and HandlerChain_Exercise.Run().
|
inline |
Convert this HandlerChain to a string, protected by a multi-threading lock.
Definition at line 143 of file HandlerChain_Class.cs.
References HandlerChain._messageHandlers, HandlerChain._messageHandlersLock, and IMessageHandler.ToString().
|
private |
The list of message handlers.
Definition at line 60 of file HandlerChain_Class.cs.
Referenced by HandlerChain.AddHandler(), MessageWindow.ProcessMessage(), HandlerChain.RemoveHandler(), HandlerChain.SendMessage(), and HandlerChain.ToString().
|
private |
Object used to lock access to the message handlers list for multi-threaded support.
Definition at line 66 of file HandlerChain_Class.cs.
Referenced by HandlerChain.AddHandler(), HandlerChain.RemoveHandler(), HandlerChain.SendMessage(), and HandlerChain.ToString().