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

fourthirtysix fourthirtysix at yahoo.com
Tue Dec 30 19:37:30 EST 2008


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.

Basically, it appears to be trying to update the GUI, but doesn't "fully"
and properly refresh until the big processes are done and i mouse into the
GUI.

During the intensive searches, I *can* get the GUI buttons to light up and I
can get a different Label.Text update to work in the statusbar.

Help!  and Thanks!



Chris Howie wrote:
> 
> On Wed, Dec 24, 2008 at 5:21 PM,  <christian.hergert at gmail.com> wrote:
>> Updates to the widget do not happen synchronously. Please make sure your
>> "Intense Database Query" is done within a thread so that gtk can continue
>> to
>> draw from its main loop when the tree model is updated.
>>
>> If you get to the point where you are doing thousands of additions to the
>> model, you may want to consider removing the model from the treeview,
>> doing
>> the updates, and then re-attaching the model. This will speed up the UI
>> because many of the model events (such as row added) do not need to be
>> handled by the treeview.
> 
> ( Directed at fourthirtysix: )
> 
> Also, updating a model that's attached to a widget from another thread
> is likely to segfault your application, or at least cause some odd
> behavior.  You would have to use Application.Invoke to do this, which
> is probably going to be very slow since it pushes a fake event on the
> event stack to be executed on the main loop (in other words, it
> involves costly cross-thread synchronization).
> 
> You might be better off using a progress bar to indicate progress.
> Just have it update every half second or so (see GLib.Timeout) from a
> value you write to on your other thread.  I've used this model with
> pretty good success.  It cuts down on the CPU usage required to update
> the visual progress meter while keeping it responsive enough that the
> user knows it's not frozen.
> 
> -- 
> 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-tp21151505p21225429.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list