Technology Microsoft Software & solutions

Multicast Delegates

< Continued from page 1

We've seen that delegates really hold the address of procedures. In fact, they can hold more than one address and when a delegate contains more than one address, it's called a multicast delegate. The list of addresses is called an invocation list. In the case of an event that calls a multicast delegate, all of the addresses in the invocation list get called.

To make that work, VB.NET provides the Combine function.


Just assign both addresses to the same delegate and combine them:

Dim myDel1 As MyDelegate = _
   New MyDelegate(AddressOf SayHelloInEnglish)
Dim myDel2 As MyDelegate = _
   New MyDelegate(AddressOf SayHelloInDeutch)
Dim myDelBoth As MyDelegate = _
   [Delegate].Combine(myDel1, myDel2)myDelBoth.Invoke()


(Note: The delegate subroutines would also have to be modified with something like ...

lblHello.Text &= vbCrLf & "Guten Tag"

... to avoid replacing the text in the label.

Related posts "Technology : Microsoft Software & solutions"

How to Import OCX

Microsoft

How to Install Grub From a Fedora Recovery CD

Microsoft

How to Speed Up Streaming in Vista

Microsoft

How to Fix a Disappearing "Start" Menu, "Start" Button and Task Bar

Microsoft

How Do I Modify Startup in Vista?

Microsoft

How to Change Your Name in CP

Microsoft

How to Use WinImage to Create a Boot Disk ISO

Microsoft

How to Get to a BIOS Screen

Microsoft

How to Control Updates on XP

Microsoft

Leave a Comment