public void Should_get_work_from_queue() { var startingUrls = new[] {"a", "b", "c"}; var loaded = 0; var jobQueue = new JobQueue(1) { QueueLoaderAction = queue => { // if (loaded > 10) // return; foreach (var url in startingUrls) { queue.Enqueue(url); } loaded++; }, WorkerAction = s => { Thread.Sleep(1000); Console.WriteLine(s); } }; var cancellataionSource = new CancellationTokenSource(); Task.Factory.StartNew(() => { Console.ReadKey(); cancellataionSource.Cancel(); }); var t = jobQueue.Start(cancellataionSource.Token); t.Wait(); }