Use of multicast in C# multicast delegates

若如初见. 提交于 2019-11-29 14:29:27

Anything acting as an event is the classic answer here - then the caller doesn't need to know who is listening (just invoke it, if it is non-null). This is ideal as multiple operations can subscribe simultaneously - for example 3 separate controls observing (data-binding) to the same property on a view-model.

Any cases where the delegate is acting as function (in particular with a return value) is tricker, as you need to think how you will handle that - take the first? Last? Aggregate?

Events are a prime example for the usage of MulticastDelegates. So, probably without realizing it, you are using them every day.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!