[Gtk-sharp-list] Window won't refresh

Brad Taylor brad at getcoded.net
Tue Jul 5 14:38:31 EDT 2005


Hi,

> I'm trying to get a TextView window to go through each line in its 
> TextBuffer and select that line at a certain pace, using some sort of timer. 
> The selection and all that works fine, so long as I manually step through 
> each line. However, if I use a timer or a thread in order to do it 
> automatically, the window will basically freeze until it gets to the last 
> line in the TextBuffer, at which point it stops, and then refreshes the 
> window again.

When you say using a thread, are you trying to update the widget from
this thread?  Just to let you know, Gtk is a single-threaded toolkit so
modifying anything from another thread will only lead to massive amounts
of badness.

> I know that it executes the code correctly, but the window 
> won't update anything until it's done with the timer. The same thing happens 
> whether I'm using a timer or thread. I'll email some source code if you need 
> it; I haven't in this message because my code is rather long and complex, 
> and would take some time to get down to the barebones.

Are you using Thread.Sleep to control these updates?  If so, you're
blocking Gtk's mainloop from working and thats why the window isn't
updating.  You should be using the GLib.Timeout set of functions to
control the timer like so:

GLib.Timeout.Add (1000, new TimeoutHandler (OnTimeout));

Maybe if you could attach a small test-case, it would be a little easier
to diagnose your problem.


Hope this helps.

-Brad

-- 
Brad Taylor
Genome Software LLC
http://www.getcoded.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://galactus.ximian.com/pipermail/gtk-sharp-list/attachments/20050705/1289534f/attachment.bin


More information about the Gtk-sharp-list mailing list