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

Mike Kestner mkestner@speakeasy.net
Fri, 17 Oct 2003 21:04:36 -0500

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.

Mike Kestner <mkestner@speakeasy.net>