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

后端 未结 2 474
予麋鹿
予麋鹿 2021-02-05 22:07

Is there big difference between those two?

相关标签:
2条回答
  • 2021-02-05 22:29

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

    0 讨论(0)
  • 2021-02-05 22:33

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

    0 讨论(0)
提交回复
热议问题