[Mono-list] Liststore not appending correctly

Nil Gradisnik ghaefbgtk at gmail.com
Thu Mar 22 04:10:54 EDT 2007


I see.
So if I wrap the whole thing inside Application.Invoke.... it should work ?
Or do I still need to create a new variable inside for loop.

Hm.. I wonder how this Application.Invoke effects performance if I use it alot.
If I'm making big calculations or long loops inside Application.Invoke ?

Thanks for all the answers

Nil Gradisnik


On 3/22/07, Miguel de Icaza <miguel at novell.com> wrote:
> Hello,
>
> > 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:
>
> First of all, you are queueing three calls: clear, the appends and the
> setting of the model.  You should do all at once.
>
> Second, like Juan pointed out what happens is that the "i" variable is
> captured, which means that they all will see the same value of i (which
> is 10 by the time the loop is over).
>
> If you want to use that setup, you need to create a new variable inside
> the for loop:
>
>         int j = i;
>
> So that you have a copy that has the value at that point in time, and
> thats the value that will get captured.
>
> For more details, see the C# specification.
>
> Miguel
>
>


More information about the Mono-list mailing list