You will need to maintain links to all tasks created in the loop. Then you can use the Task.WaitAll method (see MSDN link ). You can create an array and assign tasks to the elements of the array (in C # 2.0), or you can use LINQ:
var tasks = AAAA.Select((Entity a) => Task.Factory.StartNew(() => { myMethod(a); }, Token, TaskCreationOptions.None)).ToArray(); Task.WaitAll(tasks)
If you don't need to use tasks (explicitly), then Henk's suggestion to use Parallel.ForEach is probably the best option.
Tomas petricek
source share