Posting to an ActionBlock and waiting for completion
suggest change// Create a block with an asynchronous action var block = new ActionBlock<string>(async hostName => { IPAddress[] ipAddresses = await Dns.GetHostAddressesAsync(hostName); Console.WriteLine(ipAddresses[0]); }); block.Post("google.com"); // Post items to the block's InputQueue for processing block.Post("reddit.com"); block.Post("stackoverflow.com"); block.Complete(); // Tell the block to complete and stop accepting new items await block.Completion; // Asynchronously wait until all items completed processingu
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents