user496949
user496949

Reputation: 86135

what's the difference between static event handler and non-static event handler

Is there big difference between those two?

Upvotes: 11

Views: 6805

Answers (2)

Bradley Smith
Bradley Smith

Reputation: 13601

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...

Upvotes: 16

spender
spender

Reputation: 120498

Effectively none. All it means is that when the handler is static, there will be no this in scope (as with all static methods).

Upvotes: 5

Related Questions