[Gtk-sharp-list] Newbie's TreeView updates *very* slowly
cdhowie at gmail.com
Wed Dec 24 19:26:01 EST 2008
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.
More information about the Gtk-sharp-list