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

Mathias Tausig mtausig at fsmat.at
Tue Sep 23 04:51:37 EDT 2008


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?

cheers
Mathias

public class DisplayPanel : Gtk.MessageDialog{
       private String title, msg;
       public DisplayPanel(String s, Window parent) : base(parent, DialogFlags.DestroyWithParent, MessageType.Other, ButtonsType.None, s){
	   title="";
	   msg="";
	   Decorated=false; //keine Windowmanager Verzierungen
	   AcceptFocus=false; //Cursor wird nicht angezeigt
      }	   
																						   
   public void SetTitle(String value){
  	 title=value;
	 msg="";
	 Update();
  }
   public void SetText(String s){
	msg=s;
	Update();
   }
  public void AddText(String s){
	SetText(msg+s);
  }

  private void Update(){
    Text=title;
    SecondaryText=msg;
   ActivateDefault();
   Present();
   Stick();

   while(Application.EventsPending()){
     Application.RunIteration();
   }
 }
}


More information about the Gtk-sharp-list mailing list