[Mono-list] Liststore not appending correctly

Miguel de Icaza miguel at novell.com
Thu Mar 22 01:49:23 EDT 2007


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