It's not entirely obvious to me what's happening in this situation.
I'd expect both functions to be fired.
Either the EventHander class is storing the list of functions to fire as an array - and the array is copied to a new one every time something is added/removed - or when the assignment is made, the whole thing is copied to a new "collection" - and not just a reference.
Somebody please enlighten me :D
Here's a little Linqpad script:
public class Moop
{
public EventHandler myEvent;
}
void Main()
{
var moo = new Moop();
moo.myEvent += (o, sender) => { "Added to Moop #1".Dump(); };
var moo2 = new Moop();
//Copy the reference, I assume?
moo2.myEvent = moo.myEvent;
moo2.myEvent += (o, sender) => { "Added to Moop #2".Dump(); };
//Fire the event on #1
moo.myEvent(null, null);
}
A stagehand is a person who works backstage or behind the scenes in theatres, film, television, or location performance.
A scene is a section of your novel where a character or characters engage in action or dialogue. You can think of a scene as a story with a beginning, middle, and an end. A chapter can contain one scene or many scenes.
Why you should utilise behind the scenes content: It allows the audience to have a deeper understanding of the work involved in your company. This adds value as the client experiences a human connection and learns more from the overall product or service. It also helps to build trust and loyalty.
In cinema, behind-the-scenes (BTS), also known as the making-of, the set, or on the set, is a type of documentary film that features the production of a film or television program.
Event handler lists are delegates, and delegates are immutable -- like strings. So you do copy the delegate, and the second event handler gets "added to" the 2nd delegate, not the first.
You can find out more about delegates at http://www.c-sharpcorner.com/uploadfile/Ashush/delegates-in-C-Sharp/
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With