Using multicast in C # multicast delegates

When is it useful to have multicast delegates for delegates from a single broadcast?

I use delegates a lot, mainly in conjunction with C # lambdas, but I never felt like using the multicast aspect of C # delegates, that is, I never wanted to combine several delegates together in one delet. Therefore, I am very curious in which situation the multicast delegates are useful - I can only think of examples in which you can easily implement the functionality in some other way, for example, by combining the delegates or putting them on a list.

In particular, Eric Lippert's answer here gives the impression that even the C # team sometimes forgets about the multicast of delegates.

+4
source share
2 answers

Everything that acts as an event is the classic answer here - then the caller does not need to know who is listening (just call it if it is not null). This is an ideal solution, since several operations can be signed simultaneously - for example, 3 separate monitoring controls (data binding) to the same property on the presentation model.

Any cases when a delegate acts as a function (in particular, with a return value) are deceptive, since you need to think about how you will deal with this - take the first? Last? Cumulative?

+7
source

Events are a prime example of using MulticastDelegates. Thus, perhaps without realizing it, you use them every day.

+7
source

All Articles