static void Main(string[] args) { // LazyProducerConsumer(); var blockConfiguration = new ExecutionDataflowBlockOptions() { NameFormat = "Type:{0},Id:{1}", MaxDegreeOfParallelism = 2, BoundedCapacity = 2, }; var consumerBlock = new ActionBlock <int>(new Action <int>(SlowConsumer), blockConfiguration); for (int i = 0; i < 5; i++) { consumerBlock.Post(i); // Console.WriteLine("Sending {0}",i); // consumerBlock.SendAsync(i).Wait(); } Console.WriteLine(consumerBlock.ToString()); consumerBlock.Complete(); consumerBlock.Completion.Wait(); }
public override string ToString() => _actionBlock.ToString();