Twice this week, I've read people write that an event (.net) was "thrown". I've always thought that the verb to use with events is either "fire" or "raise". I thought that "thrown" was used for exceptions, but not events ("raise" can be used for either).
Does anyone else find it confusing for events to be "thrown"?
I agree, events are raised/fired/triggered. If anything is thrown it's exceptions.
The standard convention in the MSDN library seems to refer to Raising an Event and Throwing an Exception.
One other term is "Invoked". Since events are delgates, they are Invoked to call them, but yes the general term is either "fired" or "raised".
Also, use of the word "throw" in this context is confusing, because it will be confused with the "throw" keyword. You can't throw an event with the throw keyword.
Raise is the verb that seems to be most common in the MSDN docs.
I agree - if I hear that something was thrown, I assume it's an exception. The C# language makes that one very explicit - throw is a reserved word used with exceptions.
Although it's possible to throw
things that aren't exceptions, it's quite clear that throw
is only meant to be used with exceptions. Raise is indeed the term you'd use for signifying that an event has happened.
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