Re: Disposing of non-components in a component
Daniel Petersson <[email protected]> Wed, 30 Jan 2008 08:50:33 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <E8FBCCA96548DD46A1AC748F17EEAD9C0E96F2ACE4@cefalo-mail01.cefalo.local> |
The docs are exactly right; the Dispose( ... ) in the .designer file does just that; your solution (moving the code) is perfectly ok and I have never encountered any situation where the designer tried to modify anything but InitializeComponent( ... ) --Daniel -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Mark Hurd Sent: den 30 januari 2008 08:31 To: [email protected] Subject: [DOTNET-CLR] Disposing of non-components in a component 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(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com