예제 #1
0
        /** <inheritDoc /> */
        public bool TryEnter(TimeSpan timeout)
        {
            lock (this)
            {
                ThrowIfDisposed();

                _state++;
            }

            var res = false;

            try
            {
                return(res = UU.CacheTryEnterLock(_cache, _id, (long)timeout.TotalMilliseconds));
            }
            finally
            {
                lock (this)
                {
                    if (res)
                    {
                        _counter++;
                    }

                    _state--;
                }
            }
        }