On Tue, 2007-04-17 at 15:36 -0400, Chris Lee wrote:
> * Rewrite those parts of my app that use Gtk.Application.Invoke
> (which is possible, but not very easy or fun, as far as I can
> tell).
I thought about it for a while, and I think that the following code
pretty much does what I need without having to change the way I use
delegates.... So I can avoid gtk-2.10 for now!
public class MyApplication {
public delegate void Runnable();
public static List<Runnable> queuedForInvoke;
private static ThreadNotify notifyForInvoke;
private static void _Invoke() {
List<Runnable> cr;
lock (queuedForInvoke) {
cr = new List<Runnable>(queuedForInvoke);
queuedForInvoke.Clear();
}
foreach (Runnable r in cr) { r(); }
}
public static void Invoke(Runnable runnable) {
if ( null == queuedForInvoke ) {
queuedForInvoke = new List<Runnable>();
notifyForInvoke = new ThreadNotify (new ReadyEvent
(_Invoke));
}
lock (queuedForInvoke) {
queuedForInvoke.Add(runnable);
}
notifyForInvoke.WakeupMain();
}
}
_______________________________________________
Gtk-sharp-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list