[Gtk-sharp-list] IDisposable

adam treat manyoso@yahoo.com
Wed, 4 Sep 2002 10:51:15 -0700 (PDT)


Ok, we tried to have the Dispose method unregister the objects in the hash, but there was a
problem with Monitor locking and the GC:

  ~Pixbuf ()
  {
    Dispose ();
  }

  Dispose ()
  {
    UnregisterObject ();
  }

This should work, but when the program thread tries to access the hash for introspection and the
GC also tries to access the hash, the program freezes, regardless whether it is lock()ed in both
threads.

--- Miguel de Icaza <miguel@ximian.com> wrote:
> 
> > Right, but Dispose will never be called if the object is in the hash ;-)
> 
> Dispose is called by users of IDisposable, manually.
> 
> So I do things like:
> 
> 	Pixbuf p = new Pixbuf ("a.png");
> 	p.RenderToDrawable (...);
> 	p.Dispose ();
> 
> You are thinking about ~Pixbuf () which is indeed never called if you
> are not stored in a WeakReference
> 
> 
> Miguel
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com