Asynchronous delegates

From Figure 14.1, you can see that every delegate not only derives from MulticastDelegate, but also that several methods in addition to the Delegate and MulticastDelegate methods are available. When the compiler encounters the delegate keyword, it creates a class that extends MulticastDelegate and adds the following methods:

  • BeginInvoke

  • EndInvoke

  • Invoke

If you try to call the Invoke method directly from a delegate, you will receive the compile time error Invoke cannot be called directly on a delegate. Because each delegate can have a different signature and it is desirable to have a type safe interface, the compiler does some things automatically for you. The first thing that the compiler does is discover the number of arguments, ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.