Disposing of non-components in a component
Mark Hurd <[email protected]> Wed, 30 Jan 2008 18:00:52 +1030
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
This is related to the "Consuming your own events" thread. I have created a component in VS2008 (could have been 2005) that has one component added using the designer surface, but another IDisposable property manually added in my code. I want to (must) call the property's Dispose when disposing happens, but the boilerplate Dispose(Boolean) in the .designer file doesn't cater for user-defined disposal. (A perfect case for a Partial method.) (If my property was an IComponent I could manually add it to the components collection, and I could create a wrapper that is just for that purpose, I suppose.) The simple solution (ignoring the .designer file) is to handle the Disposed event and do the extra disposal there. What I actually did was rip the Dispose(Boolean) from the .designer file and put in my source and extended it to dispose my property. I did a fairly extensive search to see if this issue was discussed in the help files or on the web and the only reference(*) I found just says "This implementation (of Dispose(Boolean) can be overridden to provide custom cleanup code.", but it doesn't say how to. (*) ms-help://MS.MSDNQTR.v90.en/dv_fxmclicc/html/58444076-a9d2-4c91-b3f6-0e180dc0695d.htm Any definitive resources or just opinions welcome. Regards, Mark Hurd, B.Sc.(Ma.)(Hons.) =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com