Is there big difference between those two?
In programming, an event handler is a callback routine that operates asynchronously once an event takes place. It dictates the action that follows the event. The programmer writes a code for this action to take place. An event is an action that takes place when a user interacts with a program.
With a static event, there is no sending instance (just a type, which may or may not be a class). There still can be a recipient instance encoded as the target of the delegate.
Note: Event handlers are sometimes called event listeners — they are pretty much interchangeable for our purposes, although strictly speaking, they work together. The listener listens out for the event happening, and the handler is the code that is run in response to it happening.
Semantically there are no differences, however using static event handlers can (if you're not careful) lead to memory leaks. See this article for more info.
I've come across this problem myself, trying to use a static event handler to keep an application-wide data source up to date; the event handler was preventing my BindingSource
components from being disposed, leading to all sorts of weird problems...
Effectively none. All it means is that when the handler is static, there will be no this
in scope (as with all static methods).
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