Urgent Help:Removing all EventHandlers
-
Hi, I have a base Form and a base TextBox control. I have derived my Form and TextBox control from the base classes. In the base class of form, I am adding EventHandler for TextChanged Event of TextBox to do some generic operation like setting dirty flag. And again in the Derived View I am using TextChanged Event of TextBox Control to enable/disable the OK button. I am opening the form in Modal form. When I close the Form, it is not getting cleanup from memory. I checked it in .NET Profiler. In the profiler it is showing me that TextChanged EventHandler is still referring the Form. I want to cleanup all EventHandlers on Closed event of the Form. Pls let me know how I can cleanup all EventHandlers for all Controls in the Form. IT IS URGENT. Please let me know.
-
Hi, I have a base Form and a base TextBox control. I have derived my Form and TextBox control from the base classes. In the base class of form, I am adding EventHandler for TextChanged Event of TextBox to do some generic operation like setting dirty flag. And again in the Derived View I am using TextChanged Event of TextBox Control to enable/disable the OK button. I am opening the form in Modal form. When I close the Form, it is not getting cleanup from memory. I checked it in .NET Profiler. In the profiler it is showing me that TextChanged EventHandler is still referring the Form. I want to cleanup all EventHandlers on Closed event of the Form. Pls let me know how I can cleanup all EventHandlers for all Controls in the Form. IT IS URGENT. Please let me know.
If you're showing the form by calling it's
.ShowDialog()
method, you MUST call.Dispose()
on it when you're done with it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -
If you're showing the form by calling it's
.ShowDialog()
method, you MUST call.Dispose()
on it when you're done with it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming GnomeI am also calling .Dispose() after ShowDialog(). Still it is not helping...:(
-
Hi, I have a base Form and a base TextBox control. I have derived my Form and TextBox control from the base classes. In the base class of form, I am adding EventHandler for TextChanged Event of TextBox to do some generic operation like setting dirty flag. And again in the Derived View I am using TextChanged Event of TextBox Control to enable/disable the OK button. I am opening the form in Modal form. When I close the Form, it is not getting cleanup from memory. I checked it in .NET Profiler. In the profiler it is showing me that TextChanged EventHandler is still referring the Form. I want to cleanup all EventHandlers on Closed event of the Form. Pls let me know how I can cleanup all EventHandlers for all Controls in the Form. IT IS URGENT. Please let me know.
You have to manually unsubscribe.
private void Subscribe()
{
otherForm.TextChanged += new TextChangedDelegate(thisForm_TextChanged);
}private void Unsubscribe()
{
otherForm.TextChanged -= new TextChangedDelegate(thisForm_TextChanged);
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
You have to manually unsubscribe.
private void Subscribe()
{
otherForm.TextChanged += new TextChangedDelegate(thisForm_TextChanged);
}private void Unsubscribe()
{
otherForm.TextChanged -= new TextChangedDelegate(thisForm_TextChanged);
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro
Actually the problem is that I don't know what all the EventHandlers each Derived Form is using. So it's become very difficult to remove all EventHandlers from each Derived Form manually. I just want to know if there is any way to remove all EventHandlers for all controls in the Form so that I can loop through all controls in the Form and Remove it in Base Form class. Please Help.