Definition - What does Event mean?
An event is an action launched by an external hardware device and manipulated by software code. Events allow objects to notify client objects about important activities. Events provide tremendous flexibility compared to traditional console applications, which follow a rigid execution path and are limited by hard wiring. Unlike fields, events are members of an interface.
A class sending an event message is the publisher. A class receiving the event is the subscriber. Events may only be invoked from their declared classes, which requires modifier declaration (for example, protected virtual) enabling derived class access.
Techopedia explains Event
Programs apply event-driven code as external asynchronous changes occur. For example, a user pressing a keyboard button causes an external change requiring a response from its software. The triggered event is either external hardware or software. When a program indicates it is ready to react, the event is redirected to the event handler software module.
Optionally, a program may ignore and redirect events to available handlers. Triggered hardware or software event data are event type indicators, but data like precise event time or extra data affects final event handler response.
Events are always considered when hardware converts external user actions into specific event code, especially during user interface design and manufacturing.
Program event handlers are often synchronous, where one or more program code modules are dedicated to event handling. Common event sources are:
- User interfacing hardware
- Interrupting external software event, such as a timer
Event-driven interactive software alters responses according to events.
Event subscription implementation steps are:
- Event Declaration: This includes delegate (event handler) declaration with required argument set and access modifier.
- Event Invocation: Code is written when the client hooks up the event to a delegate.
- Hooking Up to Events: To hookup from outside an event's declared class, a newly created delegate instance is added to the event field with the “+=” operator.
One event may be published by multiple publishers. One subscriber may handle multiple publisher events. When multiple subscribers are registered for a single event, handlers are invoked synchronously.