Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

Name

MulticastDelegate

Synopsis

This is the base class for multicast delegates. Multicast delegates are identical to normal delegates, except that their invocation list can hold more than one method at a time. You can use Delegate.Combine() to add a method to the list and Delegate.Remove() to remove one. In C#, you can also use the + operator (or +=) to add methods. When you invoke a multicast delegate, the methods are invoked synchronously one after the other. An error in one method can prevent the delegate from calling the other methods in its list.

Multicast delegates can also be invoked asynchronously, meaning that the entire call chain is invoked serially by a single thread out of the system thread pool. If it is desirable to invoke each delegate in the chain on its own asynchronous thread instead, then use GetInvocationList() to obtain the list of delegates and asynchronously invoke each one.

public abstract class MulticastDelegate : Delegate {
// Protected Constructors
   protected method MulticastDelegate(object target, 
        string method);  
   protected method MulticastDelegate(Type target, 
        string method);  
// Public Static Methods
   public static bool operator method !=(
        MulticastDelegate d1, MulticastDelegate d2);  
   public static bool operator method ==(
        MulticastDelegate d1, MulticastDelegate d2);  
// Public Instance Methods
   public sealed override method bool Equals(object obj);       // overrides Delegate
   public sealed override method int GetHashCode();              // overrides Delegate public sealed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata