A delegate is a class. The event is similar to a property. When you declare an event in a class, you declare an event type. In this case, AlarmEventHandler , which is the inner class of the top-level class, is part.
In the OnAlarm method OnAlarm you get the instance of the AlarmEventHandler class that was assigned to this event, and call it.
To clear everything up, your code above is similar to this using regular classes and links:
public class InnerClass { public void MyMethod() { } } public InnerClass MyProperty { get; set; } protected virtual void CallMyMethod() { InnerClass cls = MyProperty; if (cls != null) cls.MyMethod(); }
thecoop
source share