I have one event in C#. There are five subscribers for that. All the subscribers are different classes. But while raising the event i want that not all the subscriber/handler should be notified to handle this event. I should have some filtering mechanism and then only remaining subscribers should be notified. What could be the best way to achieve this?
Share
If you want to do it with your existing even then just iterate through the invocation list on the event.
Now, you can see I’ve cast item.Target to a type of ICanDoThing, which is an interface I’ve just made up that exposes a method “CanDoThing”. This allows you to query the object for whether it supports your particular need.
You should probably question whether you should use an event anyway for this, but the above will allow you to do so.