Re: [MonoTouch] Implementing Dispose on an [NSObject]

2012-07-30 Thread Phil Cockfield
Thanks Rodrigo
*
*
*
*

On Fri, Jul 20, 2012 at 8:40 AM, Rodrigo Kumpera kump...@xamarin.comwrote:

 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 p...@cockfield.netwrote:

 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
 MonoTouch@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/monotouch





-- 
*Phil *Cockfield
___
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch


[MonoTouch] Implementing Dispose on an [NSObject]

2012-07-19 Thread Phil Cockfield
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
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch


Re: [MonoTouch] Implementing Dispose on an [NSObject]

2012-07-19 Thread Rodrigo Kumpera
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 p...@cockfield.net 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
 MonoTouch@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/monotouch


___
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch