I know that you need to unsubscribe from an event. My questions come from the generated code: When you change the ui from the VS editor and add an event handler to the user interface element (for example: private void BtnSampleClick(object sender, EventArgs e) )
When creating this event handling, VS adds this code to the private void InitializeComponent() code with auto-generated
this.btnSample.Click += new System.EventHandler(this.BtnSampleClick);
The problem is that VS does not add the unsubscribe ( this.btnSample.Click -= new System.EventHandler(this.BtnSampleClick); ) automatically in the form's Dispose method.
Usually should we add them there right? If this is not a memory leak? You need to check if there was a reason why VS was not automatically unsubscribing. Maybe the form is configured correctly, even if we do not?
Thank you for helping me kindle the light in this matter!
source share