Delegates and Events in C#
- by hakanbilge
Events and their underlying mechanism "Delegates" are very powerful
tools of a developer and Event
Driven Programming is one of the main Programming Paradigms. Its
wiki definition is "event-driven programming or event-based programming
is a programming paradigm in which the flow of the program is determined
by events?i.e., sensor outputs or user actions (mouse clicks, key
presses) or messages from other programs or threads." That means, your
program can go its own way sequentially and in the case of anything that
requires attention is done (when an event fires) by somebody or
something, you can response it by using that event's controller method
(this mechanism is like interrupt driven programming in embedded
systems). There are many real world scenarios for events, for example,
ASP.NET uses events to catch a click on a button or in your app,
controller has notice of a change in UI by handling events exposed by
view (in MVC pattern).
Delegates in C#
C# delegates correspond to function
pointers in [read
more....]