21
Scenario: An asynchronous task in a loop executes a method containing arguments that change as the program continues:
while(this._variable < 100)
{
this._variable++;
var aTask = Task.Factory.StartNew(() =>
{
aList.add(this._variable);
update(this._savePoint);
});
}
If the loop runs faster than the tasks complete, will the list add the current value of the variable or is the variable saved locally and the original value added?