i found a double standarts in TryPopRange ConcurrentStack methods. The name of method TryPopRange says, that it uses the TryXXX pattern, which shouldn't give you exceptions. But TryPopRange method can throw you 3 differents exceptions (ArgumentEx, ArgumentNullEx, ArgumentOutOfRangeEx). Okay, it's normal to check incoming parameters. But, if concurrent stack will be empty, i will have exception. If one thread will read all data, and my thread will use TryPopRange method i will have only exception for my read attempt.
I can understand, why they did this??
Do you refer to this overload of
TryPopRange?These exceptions are not related to the amount of items in the
ConcurrentStackcollection, but to the size of the suppliedT[] itemsargument. You are expected to pass consistent values as arguments, so you can't pass anitemsarray of size 10 and astartIndexof size 11.