I have a problem with System.Threading.Tasks
, I don't understand why it doesn't works.
Dim table_sec As New Dictionary(Of String, List(Of Double))
table_sec.Add("SEC01", New List(Of Double)(New Double() {10.00, 5.00}))
table_sec.Add("SEC02", New List(Of Double)(New Double() {9.00, 8.00}))
table_sec.Add("SEC03", New List(Of Double)(New Double() {5.00, 2.00}))
Dim pair As KeyValuePair(Of String, List(Of Double))
Dim tasks As New List(Of Task)()
For Each pair In table_sec
Dim t As Task = Task.Run(Sub()
Console.WriteLine("Key = " & pair.Key)
End Sub)
tasks.Add(t)
Next
Task.WaitAll(tasks.ToArray())
I always get this result
Key = SEC03
Key = SEC03
Key = SEC03
Can you tell me what is wrong ?