gtk-sharp2.6.0.0Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.Multi-threaded integration with Gtk support.The ThreadNotify class is used to invoke methods in the Gtk+ thread. Since Gtk is not a thread-safe toolkit, only a single thread at a time might be making calls into Gtk.Typically applications will be executing the main Gtk+ main loop and when threads are done processing work, they invoke to invoke a method on the main Gtk+ thread.
using Gtk;
class Demo {
static ThreadNotify notify;
static void Main ()
{
Application.Init ();
notify = new ThreadNotify (new ReadyEvent (ready));
Application.Run ();
}
static void ready ()
{
// Update the GUI with computation values.
}
static void ThreadRoutine ()
{
LargeComputation ();
notify.WakeupMain ();
}
static void LargeComputation ()
{
// lots of processing here
}
}
System.ObjectSystem.IDisposableMethodSystem.VoidWakeup the main thread, and invoke delegate.This methods wakes up the Gtk+ main thread and executes the delegate that was specified at construction time in the Gtk+ thread. ConstructorThreadNotify constructor
A ReadyEvent delegate.
The method referenced by the delegate will be invoked on the Gtk+ mainloop whenever any thread invokes the method.MethodSystem.VoidTo be addedMethodSystem.VoidTo be added
a