[Gtk-sharp-list] GC-Safe P/Invoke

Jonathan Pryor jonpryor@vt.edu
Fri, 17 Oct 2003 22:25:51 -0400

I had forgotten about the queuing behavior of Gtk#.  You're correct --
that probably prevents this from being an issue.

 - Jon

On Fri, 2003-10-17 at 22:04, Mike Kestner wrote:
> On Fri, 2003-10-17 at 20:25, Jonathan Pryor wrote:
> > I came across this article a couple weeks ago, and was wondering if:
> >  1. it was a concern for Gtk#
> Don't think so.  The resources allocated by Gtk# need to be freed from
> within the gui thread, so we queue up unref requests from the Dispose
> handlers called by the GC thread.  The unrefs are processed by an Idle
> Handler, so they should not run until the GUI thread is finished with
> any pending event handling.
> If I understand correctly, the scenario you describe is a GUI method
> being interrupted by the GC thread, and the dispose handler for the
> Object being called prior to resumption of the GUI thread.  If you are
> in a method already, it will finish running before we get to the Idle
> handler and process the unref queued by the Dispose method.
> >  2. if Gtk# should do something about it?
> Shouldn't need to unless I'm missing something.