Events are the messages sent by an object to indicate the occurrence of an event. Event can also be defined as a member that enables an object to provide notification. Events provide a very powerful means of inter-process communication. The most familiar example of events are graphical user interface, events are fired when any control is clicked on the GUI.
Events are not used only for graphical user interfaces. Events provide a generally useful way for objects to signal state changes that may be useful to the client of that object. In C# events are used with delegates. If you don’t have through understanding of delegates please refer the above portion. In event communication the event raiser class doesn’t know who is going to handle the event now the delegates comes into play that acts as an intermediary between the source and the receiver.
// Delegate
public delegate void newdelegate();
// Event Declaration
public event newdelegate newevent;
We can categories events into two types
- Customized Events
- Predefined Events
Comments