Delegates and Events (C#)

A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value.

Delegates have two main usages in C# programming -
1. callbacks
2. event handling
3. asynchronous method calls
5. Win32 callbacks (from Unmanaged Code)

A delegate in C# is similar to a function pointer in C or C++. It's equivalent of C/C++ callback mechanism.This feature uses Pointers to Functions to pass them as parameters to other functions.Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked

Events are the actions of the system on user manipulations (e.g. mouse clicks, key press, timer etc.) or any event triggered by the program.Events enable a class or object to notify other classes or objects when something of interest occurs. The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers.

Ref:

Delegates And Events - The Uncensored Story - Part 1 : http://www.codeproject.com/KB/cs/delegates-part1.aspx

Delegates and Event Handlers - http://www.brainbell.com/tutors/C_Sharp/Delegates_and_Event_Handlers.htm

C++ -> C#: What You Need to Know to Move from C++ to C# -
http://msdn.microsoft.com/en-us/magazine/cc301520.aspx

http://www.akadia.com/services/dotnet_delegates_and_events.html

http://www.codersource.net/csharp_delegates_events.html

http://www.codeguru.com/csharp/csharp/cs_delegates/eventhandling/article.php/c4769

http://www.jot.fm/issues/issue_2004_05/column8.pdf

http://en.csharp-online.net/CSharp_Delegates_and_Events