Events and Delegates

Events

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

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry