On 7/16/06, Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo) <[EMAIL PROTECTED]> wrote: > This is not a bug, but a C· fetaure ;-) by design. > > Destructors are not called until the memoty is needed. Period.
Yes, it's called 'nondeterministic finalisation'. The finaliser will be called, but there is no guarantee *when* it will be called. > Except the objects which implement the IIsDisposable interface. > > Suppose the Gtk.Button class implements this interface (I don't > remember if it does or doesn't). All you would have to do in your Yes, the base class Glib.Object does. There's also the explicit Gtk.Destroy method (), though that does not work as you might expect. > program is call the methods: > > button.Dispose (); > wnd.Dispose (); I'm not certain about this, but I think that the IDisposable pattern requires a disposed object to dispose its children, so you may not need to call button.Dispose (). Related info: The Dispose method is expected to be called by the object's finaliser if it is not explicitly called. If it is explicitly called, then it is expected to suppress the object's finaliser. C++/CLI implements deterministic finalisation by implementing the IDisposable pattern behind the scenes. C# also has built in IDisposable support with the 'using' keyword. -- Michael Hutchinson http://mjhutchinson.com _______________________________________________ Gtk-sharp-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
