BlockingCollection with Parallel.For hangs?
问题 I'm playing around with BlockingCollection to try to understand them better, but I'm struggling to understand why my code hangs when it finishes processing all my items when I use a Parallel.For I'm just adding a number to it (producer?): var blockingCollection = new BlockingCollection<long>(); Task.Factory.StartNew(() => { while (count <= 10000) { blockingCollection.Add(count); count++; } }); Then I'm trying to process (Consumer?): Parallel.For(0, 5, x => { foreach (long value in