I have a System.Windows.Forms.Form
like this:
public class MainForm : Form
{
int _processProgress;
public int ProcessProgress
{
get { return _processProgress; }
set
{
_processProgress = value;
if (ProcessProgressChanged != null)
ProcessProgressChanged(value);
}
}
public delegate void ProcessProgressChangedEventHandler(int progressPercentage);
public event ProcessProgressChangedEventHandler ProcessProgressChanged;
}
And it has a UserControl
like this:
public class MainFormControl : UserControl
{
public MainFormControl()
{
((MainForm)this.ParentForm).ProcessProgressChanged += (progPerc) =>
{
this.TextBox1.Text = "asd";
// Do something
};
}
}
Will it unsubscribe the Anonymous Method from the constructor of the MainFormControl
of the MainForm.ProcessProgressChanged
event when the MainFormControl.Dispose()
is called (or when the MainFormControl is removed from the MainForm)?
My code is in C#, framework 4, build in VS2010 Pro, project is in WinForms.
Please help. Thanks in advance.