2

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.

siva
  • 1,135
  • 4
  • 17
  • 25

3 Answers3

2

Refers to following link:

Is it bad to not unregister event handlers?

Community
  • 1
  • 1
Nirmal
  • 1,223
  • 18
  • 32
0

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

langtu
  • 1,198
  • 1
  • 10
  • 23
0

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

Bek Raupov
  • 3,782
  • 3
  • 24
  • 42