[Gtk-sharp-list] A big Problem wiht gtk-sharp

Jacek Rużyczka stacheldraht at interia.pl
Tue Nov 1 14:55:03 EDT 2011


Am Dienstag 01 November 2011, 18:15:48 schrieb leonel.florin at cfg.jovenclub.cu:
> Hi friends:
> Well, I have a problem that is driving me crazy, in a gtk-sharp 2.12 window
> I have a label where I represent a digital clock "00:00:00" and I create a
> thread with infinity loop that wait a second to change the label in the
> windows, this thread execute a method inside the windows where the windows
> it self change the label's text.
> The problems is, that pass a random time the windows get block, I mean,
> program remains working but the visual part of the windows get blocked.
Supposedly you ran into a big pitfall: Accessing the GUI from multiple threads 
will not work in most cases! Instead, it will lead to nasty things like the 
GUI freezing or the app crashing altogether.

But there is a workaround: Encapsulate all GUI accesses made from a sub-thread 
with Gtk.Application.Invoke(). This will synchronize these accesses, so that 
your sub-thread will not interfere any more with the main GUI thread (which, 
in theory, is the only one which has the right to do anything with the Gtk 
user interface). See the Mono documentation for details on this method.

I hope with short info will help you.

Kind regards
Jacek Rużyczka

Sprawdz za darmo zdolnosc kredytowa!	

More information about the Gtk-sharp-list mailing list