This is a mirror of official site: http://jasper-net.blogspot.com/

6 important uses of Delegates and Events

| Sunday, June 6, 2010
Introduction
Abstraction problems of methods and functions
How to declare a delegate?
Solving the abstract pointer problem using delegates
Multicast delegates
Simple demonstration of multicast delegates
Problem with multicast delegates – naked exposure
Events – Encapsulation on delegates
Implementing events
Difference between delegates and events
Delegates for Asynchronous method calls
Summarizing Use of delegates
Difference between delegates and C++ pointer
Source code
In case you do not want to read my complete article , you can watch the below video for the same.


Introduction

In this article we will first try to understand what problem delegate solves, we will then create a simple delegate and try to solve the problem. Next we will try to understand the concept of multicast delegates and how events help to encapsulate delegates. Finally we understand the difference between events and delegates and also understand how to do invoke delegates asynchronously.

Once we are done with all fundamentals we will summarize the six important uses of delegates.

This is a small Ebook for all my .NET friends which covers topics like WCF,WPF,WWF,Ajax,Core .NET,SQL etc you can download the same from here
or else you can catch me on my daily free training @  from here  

Abstraction problems of methods and functions

Before we move ahead and we talk about delegates let’s try to understand what problem does delegate solve. Below is a simple class named ‘ClsMaths’ which has a simple ‘Add’ function. This class ‘ClsMaths’ is consumed by a simple UI client. Now let’s say over a period of time you add subtraction functionality to the ‘ClsMaths’ class, your client need to change accordingly to accommodate the new functionality.

Read more: Codeproject

Posted via email from jasper22's posterous

0 comments: