diff --git a/ChangeLog b/ChangeLog index 4c218ee7b..13d0b2091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-09-02 Miguel de Icaza + + * gtk/Application.cs (Invoke): Add new overloads to easily invoke + methods on the executing thread. + +2005-09-01 Miguel de Icaza + + * gtk/Application.cs (Invoke): Add sugar to invoke a method on the + main thread. + 2005-09-02 Ben Maurer * sample/NodeViewDemo.cs: take advantage of the stuff below diff --git a/gtk/Application.cs b/gtk/Application.cs index d911e64d5..3787c2073 100755 --- a/gtk/Application.cs +++ b/gtk/Application.cs @@ -141,5 +141,45 @@ namespace Gtk { return new Gdk.Event (gtk_get_current_event ()); } } + + internal class InvokeCB { + EventHandler d; + object sender; + EventArgs args; + + internal InvokeCB (EventHandler d) + { + this.d = d; + args = EventArgs.Empty; + sender = this; + } + + internal InvokeCB (EventHandler d, object sender, EventArgs args) + { + this.d = d; + this.args = args; + this.sender = sender; + } + + internal bool Invoke () + { + d (sender, args); + return false; + } + } + + public static void Invoke (EventHandler d) + { + InvokeCB icb = new InvokeCB (d); + + GLib.Idle.Add (new GLib.IdleHandler (icb.Invoke)); + } + + public static void Invoke (object sender, EventArgs args, EventHandler d) + { + InvokeCB icb = new InvokeCB (d); + + GLib.Idle.Add (new GLib.IdleHandler (icb.Invoke)); + } } }