Events in C Sharp (C#)
An event is a notification sent by an object to signal the occurrence of an action. Events in .NET follow the observer design pattern.
The class who raises events is called Publisher, and the class who receives the notification is called Subscriber. There can be multiple subscribers of a single event.
Typically, a publisher raises an event when some action occurred. The subscribers, who are interested in getting a notification when an action occurred, should register with an event and handle it.
In C#, an event is an encapsulated delegate. It is dependent on the delegate . The delegate defines the signature for the event handler method of the subscriber class.
Declare an Event
An event can be declared in two steps:
The following example shows how to declare an event in publisher class.
public delegate void Notify(); // delegate
public class ProcessBusinessLogic
{
public event Notify ProcessCompleted; // event
}