Jon Skeet [C# MVP] wrote:
Edward Diener <ed******@tropicsoft.com> wrote: I am surprised that a MulticastDelegate does not have a particular
member function which checks if a particular delegate is in its
invocation list. I can do this manually of course but a Find, or
something like that, should have been a member function of the
MulticastDelegate.
I don't think it's the kind of thing that's used very often, to be
honest. I certainly have never needed it myself, and I can't remember
anyone ever asking for it before...
It could be used to make sure that a delegate referencing the same member
function is not added twice or removed if it is not already there. The
former is more important as I assume attempting to remove a delegate which
does not already exist does nothing. However adding the same member function
twice is probably not wise.
It might be argued that any code which could add the same handler twice is
flawed in it design, and that may be so. When you replied I re-checked my
code that I was writing to prevent that and realized that if my logic was
correct, it could not happen by design. However I can imagine situations
where a Find might be useful, or a MulticastDelegate function which only
adds a delegate handler if that delegate handler does not already exist in
its invocation list might be useful.