This is a cumbersome behaviour when creating several task in a for loop:
Private Sub DoSomeTasks()
For i = 1 to 3
Dim oTest as cTest = New cTest
Dim oTask As Task = Task.Factory.StartNew(Sub() oTest.DoSimulation(i))
Next
End Sub
This code will create all tasks with the same i value (= 3). Anyone has experienced something similar? Anyone has a clue on how to solve it?