简体   繁体   中英

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

这两者有很大的不同吗?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM