[Gtk-sharp-list] Newbie's TreeView updates *very* slowly

fourthirtysix fourthirtysix at yahoo.com
Wed Dec 31 13:42:10 EST 2008

Hi Chris,

This did the trick perfectly. Thanks!  The combination of splitting the
database/memory intesive parts of the program into Threads was the first
step.  Then, your suggestion to use Application.Invoke got the GUI to update
more cleanly while the intensive operations were still running.

Now I'm off to work on the next section of the program.  Thanks again!

Chris Howie wrote:
> On Tue, Dec 30, 2008 at 7:37 PM, fourthirtysix <fourthirtysix at yahoo.com>
> wrote:
>> I've read over many of the suggestions and links in the replies, thank
>> you to
>> everyone, and have added in Threading to keep the GUI responsive. There
>> is
>> one weird catch however--
>> I load about 500,000 records into a huge ArrayList and then run multiple
>> searches over that. Each time I iterate over the big list, it generates a
>> "hit" and I want to update the ListStore. I do so with an AppendValues,
>> however the GUI does not refresh completely.
>> I can see it "sort of" refresh for some of my hits.. It will put in a few
>> values for each row, or add in a zero as placeholders, but it does not
>> update the entire screen properly until the hits are mostly in and I
>> actually move the mouse cursor into the treeview section of the GUI. It
>> may
>> be that I have to hover over an actual Row, but I need to test some more.
> Usually this is a symptom of invoking AppendValues on the model from a
> different thread than the GTK+ event loop thread.  Make sure that you
> are using Application.Invoke each time you touch the model from a
> different thread, like this:
> Application.Invoke(delegate {
>     foreach (object i in something) {
>         model.AppendValues(i);
>     }
> });
> You can invert the nesting there (iterate and call Invoke instead of
> iterating inside the delegate) if the results come in slowly enough
> that doing cross-thread synchronization doesn't slow it down
> significantly.  Otherwise doing one cross-thread call and throwing a
> whole batch in at once is the way to go.
> (Note that Application.Invoke does *not* wait for the delegate to be
> executed.  It returns immediately after pushing the delegate on the
> event stack, so careful your code doesn't step on itself.)
> -- 
> Chris Howie
> http://www.chrishowie.com
> http://en.wikipedia.org/wiki/User:Crazycomputers
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

View this message in context: http://www.nabble.com/Newbie%27s-TreeView-updates-*very*-slowly-tp21151505p21235641.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

More information about the Gtk-sharp-list mailing list