Created
March 20, 2019 17:11
-
-
Save ronnieoverby/1f1750e67ca3c5b7af15b9abc31fd331 to your computer and use it in GitHub Desktop.
This file contains 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