using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
public static void Main()
var tasks = new List<Task>();
int maxThreads = 50, threadWaitTime = 3000;
var token = new CancellationToken();
var bbrQueue = new ConcurrentQueue<string>();
while (0 == 0 && !token.IsCancellationRequested)
if (bbrQueue.TryDequeue(out key))
Thread.Sleep(threadWaitTime);
if (tasks.Count >= maxThreads)
Task.WaitAll(tasks.ToArray(), token);
var bbrCollection = new BlockingCollection<string>();
foreach (var sku in bbrCollection.GetConsumingEnumerable(token))
if (tasks.Count >= maxThreads)
Task.WaitAll(tasks.ToArray(), token);