My (admittedly shaky) understanding is that you should be able to add any number of delegates to a C# event, and they all get invoked (in some undefined order). But that does not appear to be the case in my project. I've got it boiled down to two delegates added to the Activated event of an NSButton (this is in MonoMac), like so:
nsButton = new NSButton(new System.Drawing.RectangleF(0, 0, 100, 100));
nsButton.StringValue = "Click me!";
nsButton.Activated += delegate(object sender, EventArgs e) {
Console.WriteLine("Handler 1!");
};
nsButton.Activated += delegate(object sender, EventArgs e) {
Console.WriteLine("Handler 2?");
};
(and then this button gets added to a window, of course). When I click it, I see "Handler 1!" but I do not see "Handler 2?" appear in the Console. If I comment out the lines that add handler 1, then handler 2 fires.
It is behaving exactly as if only the first delegate added works, and any subsequent ones are ignored. But this defies everything I can find about how events in C# are supposed to work. What am I doing wrong?