I think (my opinion) Application.Invoke should work as you expect it to
work. By this I mean it should not queue the delegate but to execute it
before it returns. But as i see, it's adding the delegate to a queue, that's
why it's adding just 9, 9, 9, 9... because when it executes the delegate, i
== 9, and you may be already out of the loop.
That's my theory but I don't have answers. I think the Control.Invoke method
in Windows waits until the delegate is executed and then it returns, but
this is other toolkit... so they can have different behavior :)
Anyway, try other options:
http://www.mono-project.com/Responsive_Applications
JCO
On 3/21/07, Nil Gradisnik <[EMAIL PROTECTED]> wrote:
I need your opinion on this one. I'm running a Thread which starts this
function named PopulateTreevew() and in there this is what happens:
//populate treeview
public void PopulateTreeviewThreadRoutine()
{
Gtk.Application.Invoke (delegate {
liststore.Clear();
});
for (int i = 0; i < 10; i++) {
Console.WriteLine (i); //THIS one works
Gtk.Application.Invoke (delegate {
Console.WriteLine (i); //THIS one sometimes works
liststore.AppendValues (i);
});
}
Gtk.Application.Invoke (delegate {
Treeview1.Model = liststore;
});
}
My main problem is that I sometimes get all the same(the last) contents
of my variable array to my Treeview, using liststore.AppendValues... I
tested this values with Console.WriteLine.
As you can see I'm using Gtk.Application.Invoke, because I'm running a
Thread outside the main GTK thread.
So basically I narrowed it down to this, that if I print out those
variables(arrays) before the Gtk.Application.Invoke, it always prints
out OK, the numbers(i) are 0,1,2,3,4,5,6...9. But If I print them out
inside Gtk.Application.Invoke I sometimes(randomly) get just all 9s !
That is 9,9,9,9,9.......9.
Why is that ? What could cause this problem, I don't understand.
It looks like a bug in Gtk.Application.Invoke or something.
Can I use something else than Gtk.Application.Invoke, so that I get out
the correct array?
Because it looks like the Gtk.Application.Invoke messes up things
randomly.
Please advise
Thanks
Nil Gradisnik
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list
--
Juan Cristóbal Olivares
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list