[Gtk-sharp-list] GTK# app "hanging"

Raúl Moratalla raul.moratalla@ono.com
Tue, 22 Feb 2005 23:16:22 +0100


Thanks for your info Jon but I have the following question.
I added a line like this in my program:

Gtk.Timeout.Add(0,delegate{m_Log(this,importance,strMsg);});

If I compile my program I get the following error:
Not all code paths return a value in anonymous method of type 
`Mono.CSharp.AnonymousMethod'(CS1643)

What am I doing wrong?

Cheers,

Raúl

El Martes, 22 de Febrero de 2005 12:54, Jonathan Pryor escribió:
> On Tue, 2005-02-22 at 10:46 +0000, Manuel Capinha wrote:
> > The watcher object is threaded and is responsible for updating the
> > images. This is done by creating a WebRequest object that points to
> > the image in a webserver. The Gdk.Image object is updated with:
> >
> >     image.Pixbuf = new
> > Gdk.Pixbuf(request.GetResponse().GetResponseStream());
>
> Assuming that the thread that executes the above is NOT your GUI thread,
> that is your problem. :-)
>
> In GTK+/Gtk#, you can only update the GUI from the GUI thread.  All
> other threads MUST NOT modify the GUI, as this will cause random hangs
> (like you're seeing).
>
> The solution is to add a callback to the GUI thread which will update
> the GUI.  Callbacks can be added via GLiub.Timeout.Add.
>
> In C# 2.0, you could do:
>
> 	Stream stream = request.GetResponse().GetResponseStream();
> 	GLib.Timeout.Add (0, delegate {
> 		image.Pixbuf = new Gdk.Pixbuf (stream);
> 	});
>
> C# 1.1 implementations are left as a problem for the reader. :-)
>
>  - Jon
>
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list