[Gtk-sharp-list] GUI don't refresh the progress bar

Chris Howie cdhowie at gmail.com
Sat Oct 11 14:31:45 EDT 2008


On Sat, Oct 11, 2008 at 12:40 PM, YyYo <yossiozani at gmail.com> wrote:
> I just started using GTK#, and until now i did use gtk using Pytgk and
> perl-gtk2.
>
> For learning the GTK# (and C# language), I wrote a simple app which suppose
> to show progress bar progress(by separate thread).
> The main Idea is that the progress bar will continue to work while the user
> cound be able to work with other widget of the  GUI simultaneously.
>
> when I run the app, I can't see any progress of the progress bar, even
> though I increase the "fraction" value. I only see movement only when the
> "fraction" value equals 1(at the end of the loop)

You need to execute all GUI code on the main loop.  So you might write
yourself a helper method:

void UpdateProgressFraction(float f) {
    Application.Invoke(delegate {
        progressbar.Fraction = f;
    });
}

Then use this instead of setting progressbar.Fraction.  (Obviously,
only do this from other threads as it incurs some overhead.)

-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers


More information about the Gtk-sharp-list mailing list