[Gtk-sharp-list] Responsive Applications
White Spirit
wspirit at homechoice.co.uk
Sat Jan 6 12:55:11 EST 2007
Matteo Bertozzi wrote:
> I don't have understand the Responsive Application "Lesson" at
> http://www.mono-project.com/Responsive_Applications
> Why OnButtonClick() Code Freeze the GUI?
> and how i could correct it?
The problem is here:
> Gtk.Application.Invoke (delegate {
> Thread.Sleep(1800 + 3600);
> button.Label = "End Hard Work";
> });
The code in the event handler is already running in the GTK thread.
Your code attempts to pass the code to the GTK thread from within the
GTK thread.
Gtk.Application.Invoke is only used within threads other than the GTK
thread (because GTK# is not 'threadsafe'). So, if you had a thread
called mythread, once that thread was started you would use
Gtk.Application.Invoke to access GTK objects safely.
More information about the Gtk-sharp-list
mailing list