[Gtk-sharp-list] Thread-safe GUI update
Leon Stringer
leon.stringer at ntlworld.com
Sun Mar 25 16:13:40 EDT 2007
William Garrison wrote:
> Wouldn't using a regular delegate eliminate this issue? It would copy
> msg onto the stack for the call so the value wouldn't be overwritten
> during the next loop. (I'm not sure if this code is quite right, but
> you get the idea)
>
> while (Messages.Count > 0) {
> msg = (Message) Messages.Dequeue();
> send(msg);
> Gtk.Application.Invoke(AppendAValue,msg);
> Thread.Sleep(0);
> }
>
> private void AppendAValue(Message msg)
> {
> treeStore.AppendAvlues(msg.To, msg.Text);
> }
I realise you've done this example off the top of your head but do you
know of any working examples?
As far as I can see I have to do something like:
Gtk.Application.Invoke(this, msg, AppendAValue);
but it won't compile because msg isn't the right type (EventArgs).
Unfortunately the example in the Mono docs
(http://www.go-mono.com/docs/monodoc.ashx?tlink=5@ecma%3a705%23Application%2fM%2fInvoke%2f9)
doesn't actually show how to do this...
More information about the Gtk-sharp-list
mailing list