Created
March 20, 2019 17:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var queue = new BlockingCollection<object>(); | |
// ... meanwhile some other thread is adding to the queue | |
Task.Run(() => | |
{ | |
for (int i = 0; i < 10; i++) | |
queue.Add(i); | |
queue.CompleteAdding(); | |
}); | |
foreach (var item in queue.GetConsumingEnumerable()) | |
{ | |
// do something with item | |
item.Dump(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment