[Gtk-sharp-list] Gtk# & background threads

Adam Tauno Williams adam at morrison-ind.com
Sun Sep 14 14:43:31 EDT 2008


I understand that all modifcations to the UI must be performed in the  
"main" thread via Application.Invoke() or some such mechanism.

But can widgets be created in another thread and then provided to the  
main thread to be added to the UI?  Like:

delegate Gtk.VBox SummaryLoader(Whitemice.ZOGI.Entity  entity,
		                IList<Whitemice.ZOGI.ObjectLink> links);
....
Viewport viewport;

viewport.Child = new Label("Loading links...");
SummaryLoader loader = delegate(Whitemice.ZOGI.Entity  e,
	                        IList<Whitemice.ZOGI.ObjectLink> l)
{
   VBox 	 v = new VBox();
   v.Spacing = 2;
   foreach(Whitemice.ZOGI.ObjectLink link in l)
   {
		... compose expensive widget (olf) ...
     v.PackStart(olf, false, false, 2);
   }
   return v;
};

loader.BeginInvoke (entity, links, delegate (IAsyncResult r)
{
   viewport.Remove(viewport.Child);
   viewport.Child = loader.EndInvoke(r);
}, null);




More information about the Gtk-sharp-list mailing list