using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
var collection = new Dictionary<int, string>();
var tasks = Enumerable.Range(1, 2000).Select(async num =>
var rnd = new Random().Next(1, 5);
await Task.Delay(TimeSpan.FromSeconds(rnd));
collection[num] = $"index {num}";
await Task.WhenAll(tasks);
Console.WriteLine("All tasks complete");