[Gtk-sharp-list] Updating of a window not done right away

Mathias Tausig mtausig at fsmat.at
Thu Sep 25 03:49:17 EDT 2008


Am 24. Sep 2008 um 16:50:02 -0300, schrieb Pedro Guridi:
>    I'm not sure if we are talking about the same thing.
>    But what I'm saying, it's for the case when you have a long operation, or
>    some long while/for, and because of that the gtk main loop will
>    not be able to update the gui, or receive any event until the loop ends.
>    To solve that you can add this inside the blocking loop (assuming that
>    runs in the main thread than Gtk, that's the point after all) :
> 
>  while (Gtk.Application.EventsPending ())
> 
>          Gtk.Application.RunIteration ();

Look at my code snippet in my inititial mail. That's exaclty what I am doing in my DisplayPanel class, whenever I change the text. That's why I consider this behaviour to be so weird

> 
>    Question.., I guess you are using these: "Thread.Sleep(3000)" for giving
>    the gtk main thread a time to update the gui, I'm right?.
>    if this is the case, try putting the code above instead of the
>    "Thread.Sleep(3000);".

The Thread.Sleep only exists in this short example function. In reality, a longish and blocking function (a pinpad verification of a smartcard) is executed.

cheers
Mathias

> 
>    regards,
>    Pedro
> 
>    On Wed, Sep 24, 2008 at 4:26 PM, Michael Hutchinson
>    <[1]m.j.hutchinson at gmail.com> wrote:
> 
>      On Wed, Sep 24, 2008 at 4:52 AM, Mathias Tausig <[2]mtausig at fsmat.at>
>      wrote:
>      > Am 23. Sep 2008 um 23:43:04 -0400, schrieb Michael Hutchinson:
>      >> On Tue, Sep 23, 2008 at 4:51 AM, Mathias Tausig <[3]mtausig at fsmat.at>
>      wrote:
>      >> > Hy!
>      >> >
>      >> > I wrote a class DisplayPanel (see below., which should just display
>      some text right away. The problem is, it just doesn't do that if I start
>      some blocking function after setting the text. If I execute
>      >> >
>      >> > Gtk.Window w = new Gtk.Window("Test");
>      >> > w.Show();
>      >> > for(int i=0;i<20;++i){
>      >> >        DisplayPanel dp = new DisplayPanel("",w);
>      >> >        dp.SetTitle(i);
>      >> >        Thread.Sleep(3000);
>      >> >        dp.Dispose();
>      >> > }
>      >> >
>      >> > sometimes it does display the correct text right away, but
>      sometimes (rather unpredictable, about every third time) I get just an
>      empty Window.
>      >> > Does anyone have an idea, what might cause this?
>      >>
>      >> You're blocking the main loop. The main GTK loop handles repainting,
>      >> firing events, etc.
>      >
>      > I know. But in my class, when calling SetTitle, I have a loop that
>      executes RunIteration as foten as neccesary which, as far as I have
>      understood the loop, should do all the update, as it is executed before
>      the blocking call.
> 
>      I'm not an expert on that API, but doesn't it just clear the event
>      queue and carry on? Ass soon as it's finished you will hit the
>      blocking code.
>      --
>      Michael Hutchinson
>      [4]http://mjhutchinson.com
>      _______________________________________________
>      Gtk-sharp-list maillist  -  [5]Gtk-sharp-list at lists.ximian.com
>      [6]http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> 
> References
> 
>    Visible links
>    1. mailto:m.j.hutchinson at gmail.com
>    2. mailto:mtausig at fsmat.at
>    3. mailto:mtausig at fsmat.at
>    4. http://mjhutchinson.com/
>    5. mailto:Gtk-sharp-list at lists.ximian.com
>    6. http://lists.ximian.com/mailman/listinfo/gtk-sharp-list


More information about the Gtk-sharp-list mailing list