Allocates resource and returns number of remaining resources. If the initial number of resources is 0, then the call will block until a resource becomes available. If there are no remaining resources (Result is 0), sets externally visible event.
Slightly different from the IEnumerable: - Returns TOmniValue. - Must ensure correct operation of multiple simultaneous enumerators. - TryTake must be implemented to support mutable collections (as TOmniBlockingCollection). For non-mutable collections TryTake can simply return false if the collection is empty. - TryTake must be threadsafe - when used in Parallel.For, data manager will call it simultaneously from multiple threads at the same time.
When throttling is set, Add will block if there is >= highWaterMark elements in the queue. It will only unblock when number of elements drops below lowWaterMark.