i2005-09-02 Miguel de Icaza <miguel@novell.com>

* gtk/Application.cs (Invoke): Add new overloads to easily invoke
	methods on the executing thread.



svn path=/trunk/gtk-sharp/; revision=49379
This commit is contained in:
Miguel de Icaza 2005-09-02 22:39:17 +00:00
parent e4682de9cf
commit 95a22dd13b
2 changed files with 50 additions and 0 deletions

View File

@ -1,3 +1,13 @@
2005-09-02 Miguel de Icaza <miguel@novell.com>
* gtk/Application.cs (Invoke): Add new overloads to easily invoke
methods on the executing thread.
2005-09-01 Miguel de Icaza <miguel@novell.com>
* gtk/Application.cs (Invoke): Add sugar to invoke a method on the
main thread.
2005-09-02 Ben Maurer <bmaurer@ximian.com>
* sample/NodeViewDemo.cs: take advantage of the stuff below

View File

@ -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));
}
}
}