public int Release (int releaseCount)
{
CheckState ();
if (releaseCount < 0)
throw new ArgumentOutOfRangeException ("releaseCount", " The releaseCount must be positive.");
// As we have to take care of the max limit we resort to CAS
int oldValue, newValue;
do {
oldValue = currCount;
newValue = (currCount + releaseCount);
newValue = newValue > max ? max : newValue;
} while (Interlocked.CompareExchange (ref currCount, newValue, oldValue) != oldValue);
return oldValue;
}