Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To: Auto Dispose a Custom Control?
Message
From
23/02/2007 12:06:27
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01198325
Message ID:
01198357
Views:
11
Ben,

It should call the Dispose automatically ... you shouldn't have to worry about it.

How did you create the custom control? Is it sub-classed from UserControl? It probably should be if it's not. And how did you create the dispose method? Did you override the base class Dispose?

~~Bonnie



>I created a custom control in my application which accesses a global collection of DataSets, adding a private DataSet for the control. WHen the form that houses the control closes, I want the control to then remove the private DataSet it created in the global collection. I used "Implements IDisposable" in my custom control, but when the form closes the control's Dispose method does not run. It does run however, when I terminate the entire application, I assume because the Garbage Collector at this point realizes that nothing is referencing the object in memory any longer.
>
>How di I get the dispose method of the control I created to run automatically when it's parent container form closes? I want to avoid calling .Dispose manually because then whoever uses this control has to remember to manyally dispose the control each time it's used, otherwise there will be memory left in use for datasets that are no longer needed.
>
>Help! :-)
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform