The ASP.NET page framework provides a technique called event bubbling that allows a child control to propagate events up its containment hierarchy. Event bubbling enables events to be raised from a more convenient location in the controls hierarchy and allows event handlers to be attached to the original control as well as to the control that exposes the bubbled event.
Sometimes you need to handle one event on different layers of the class hierarchy. Take for example, the following case:
You need to implement a system which will receive data from the serial connection, parse it to single out several commands and handle them accordingly. The application will have to report its activity to a form. The form must present:
- a list of several connections
- the number of bytes sent and received for each connection
- last executed command for each connection
One of the possible approaches is:
- create a base class for low-level serial communication (
Connection) - create a class that will handle the commands and send the response back to the caller (
Communicator) - create a class that will contain several
Communicators (CommManager)
You need to handle the following events:
OnData
It is fired when data is sent or received to/from the serial port.
OnCommand
It is fired when a command has been handled by the Communicator.
OnError
If any errors occur in the data transmission, this event is fired by Connection.
Reference: http://msdn2.microsoft.com/en-us/library/aa719644(VS.71).aspx#Mtps_DropDownFilterText
No comments:
Post a Comment