开发者

Subscribing and Unsubscribing of Events [duplicate]

开发者 https://www.devze.com 2023-02-23 02:56 出处:网络
This question already has answers here: Is it bad to not unregister event handlers? (2 answers) Closed 9 years ago.
This question already has answers here: Is it bad to not unregister event handlers? (2 answers) Closed 9 years ago.

I have a Winform, i have added a few controls like Textbox, buttons. I subscribed to the textbox Changed event, teh button click event. The designer automatically adds the += statements i.e subsribtion of events in the designer.cs file.

My question is should we add the unregisterig of these events in the dispose function ? is it necesssary, or will there be any leak if i do not unregister. Or is it that .NET takes care of it开发者_如何转开发.


Refers to following link:

Is it bad to not unregister event handlers?


This is not required to unregister events that is subscribed on same class.


If your WinForm is the only one that is consuming/subscribing to it, then you dont need to worry about unsub.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号