ConcurrentStack<T> is a thread-safe generic LIFO collection for concurrent insertion and removal. Push adds items, while TryPop combines checking and removal so another thread cannot claim the item between separate operations. section 13.2.4
Use ConcurrentStack<T> when:
- Multiple threads need concurrent access to a stack. section 13.2.6
- The application does not need a built-in signal that an item is available. section 13.2.6
- A consumer must wait for work or producers must be bounded; wrap it with BlockingCollection<T> instead. section 13.2.2
ConcurrentStack<T> works in asynchronous and non-asynchronous code. BlockingCollection<T> can use it as a backing collection, preserving LIFO order while consumers wait for items when the stack is empty. section 13.2.6 section 13.2.2
