-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Akshit56491
Message 2 in Discussion

Hi Koduri,   The .NET Framework distinguishes between two kinds of delegates, those 
with multiple associated functions, referred to as multicast delegates, and those with 
only a single associated function, called single-cast delegates. With a multicast 
delegate, the .NET Framework internally builds a linked list of function pointers and 
calls each of them in turn when the delegate is invoked. Methods are added to the 
internal list via the Delegate class�s Combine method, which in C# is mapped to the += 
construct. To remove a method from a delegate�s invocation list, use the Remove 
method, or in C#, the -= operator.

Thus, to extend our original example a bit further, if a second class method, 
NotifyMeToo, also needs notification when Notifier finishes its work, you could use 
code like that found in Listing D. When NotifyDelegate is invoked, Caller.Notify and 
Caller.NotifyMeToo are each invoked in turn.

I should point out that the multiple methods in a delegate�s invocation list need not 
be on the same object instance or even declared as part of the same class. So in this 
case, NotifyMeToo doesn�t necessarily have to be a method on the same instance of 
Caller and could even be declared on a separate class from the original Notify method. 
Also, bear in mind this (hopefully) rather obvious point: Two different instances of 
Notify will have two different internal instances of NotifyDelegate. An invocation of 
one will not result in the calling of methods registered on the other.

Finally, a couple of rules govern what can and can't be a multicast delegate:
        �        The return type of the delegate must be void (a sub in VB.NET).       
 �        The parameter list must not include any out parameters (byRef for VB.NET).
If these two rules are not met, any attempt to add a function to a delegate�s 
invocation list will result in a compile-time error.
   Regards, Akshit

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to