May 2010
Intermediate to advanced
1272 pages
61h 18m
English
ConcurrentBag(Of T)The ConcurrentBag(Of T) is the most basic concurrent collection, in that it is just an unordered collection of items. The following code demonstrates how you use it for adding, iterating, counting, and removing items:

You add items to the collection by invoking the Add method. The Count property gets the number of items in the collection, whereas the IsEmpty property tells you if the collection is empty. To remove an item, you invoke TryTake, which takes the first item, assigns it to the result variable (in this case anItem), and then removes it from the collection. It returns True if removing succeeds, otherwise False. Keep ...
Read now
Unlock full access