July 25, 2008

Raise The Roof

I've discovered that - ok, I sort of already knew - that with the more pleasing, IMO, syntax and increased flexibility with using C# for my Combat Tracker, I've inherited a greater ability to shoot myself in the foot.

This came to me when I first tried to raise an event from one of my data objects. In VB.NET, RaiseEvent doesn't care one way or another about whether anyone's listening. When you raise, or invoke, an event in C#, though, you need to make sure that the event in question has listeners (basically that EventWeAreAboutToRaise != null).

Which is just kind of silly. I agree that you should be able to see and possibly iterate through your listeners, but to require that you have them to raise the event just seems kind of silly.

0 comments: