C# one event with multiple subscribers issues with ordering

I have a class , lets call it class A . Class A has an event "OnSendData" . And there is another class named B . Class A has an arraylist with references of class B . Class A create instances of class B when something happens and add them to its arraylist . In class B constructor i have a code like this :

Public B (A parent)
{ Parent.OnSendData += parent_OnSendData; } 

When i invoke class A event , my event subscribers calls in order of subscribtion . I dont want this , i want them all to notify at once . What should i do for this to happen ??

Jon Skeet
people
quotationmark

Where you're raising the event, you can call Delegate.GetInvocationList to get all the subscribers - and then use a separate task or thread per subscriber to call them all in parallel.

Note that your subscribers will have to be thread-safe for this to work - and neither ArrayList nor List<T> (you should be using the latter; ArrayList is so 2004...) are thread-safe, so you'd need extra locking etc.

people

See more on this question at Stackoverflow