You should only override "void Dispose (bool disposing)", and make sure to always call the base method.
On Thu, Jul 19, 2012 at 5:15 PM, Phil Cockfield <[email protected]> wrote: > What's the correct way of hooking into the *Dispose* invokation in > classes derived from *NSObject*? > > I have an example in the gist here <https://gist.github.com/3146438>. > https://gist.github.com/3146438 > > This is the full IDisposable pattern as I've seen it declared in the MSDN > docs. There's a lighter weight version in the comment below. > > The problem is, NSObject implments IDisposable itself, and doesn't appear > to provide any overridable *OnDisposing* type methods. I get a build > warning saying to use the "*new*" keyword on my Dispose method. > > "new" is dangerous to use (right?). If the object is cast as NSObject, > and Dispose is run - then the parent method will run, but my derived method > won't. That's my understanding at least, please correct me if I'm wrong. > > So what is the best practice for hooking into dispose in these types of > scenarios? Thanks! > > -- > *Phil *Cockfield > > > > > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch > >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
