I tear off my hair due to the following problem. I have this bit of code that iterates over a list of objects and creates a processing task for each of them.
IList<TileInfo> tiles = tileSource.Schema.GetTilesInView(extent, level); List<Task> renderingTasks = new List<Task>(); foreach (TileInfo info in tiles) { renderingTasks.Add(Task.Factory.StartNew(new Action(delegate { Console.WriteLine(Task.CurrentId +"Info object"+ info.GetHashCode()); } }))); }
This code prints:
1Info object36963566 2Info object36963566 3Info object36963566 4Info object36963566 5Info object36963566 6Info object36963566 7Info object36963566 8Info object36963566 9Info object36963566 10Info object36963566 11Info object36963566 12Info object36963566 ...
As you can see, the problem is that tasks seem to all have a reference to one object!
Why do all tasks use only one object from the list?
thanks for the help
Getah source share