public async Task <IConnectionHandle> AcquireConnectionAsync(CancellationToken cancellationToken)
        {
            var helper = new AcquireConnectionHelper(this);

            try
            {
                helper.CheckingOutConnection();
                ThrowIfNotOpen();
                helper.EnterWaitQueue();
                var enteredPool = await _poolQueue.WaitAsync(_settings.WaitQueueTimeout, cancellationToken).ConfigureAwait(false);

                var connectionHandle = await helper.EnteredPoolAsync(enteredPool, cancellationToken).ConfigureAwait(false);

                return(connectionHandle);
            }
            catch (Exception ex)
            {
                helper.HandleException(ex);
                throw;
            }
            finally
            {
                helper.Finally();
            }
        }
Esempio n. 2
0
        // public methods
        public IConnectionHandle AcquireConnection(CancellationToken cancellationToken)
        {
            ThrowIfNotOpen();

            var helper = new AcquireConnectionHelper(this);

            try
            {
                helper.CheckingOutConnection();
                var enteredPool = _poolQueue.Wait(_settings.WaitQueueTimeout, cancellationToken);
                return(helper.EnteredPool(enteredPool));
            }
            catch (Exception ex)
            {
                helper.HandleException(ex);
                throw;
            }
            finally
            {
                helper.Finally();
            }
        }
        public async Task<IConnectionHandle> AcquireConnectionAsync(CancellationToken cancellationToken)
        {
            ThrowIfNotOpen();

            var helper = new AcquireConnectionHelper(this);
            try
            {
                helper.CheckingOutConnection();
                var enteredPool = await _poolQueue.WaitAsync(_settings.WaitQueueTimeout, cancellationToken).ConfigureAwait(false);
                return helper.EnteredPool(enteredPool);
            }
            catch (Exception ex)
            {
                helper.HandleException(ex);
                throw;
            }
            finally
            {
                helper.Finally();
            }
        }
        // public methods
        public IConnectionHandle AcquireConnection(CancellationToken cancellationToken)
        {
            ThrowIfNotOpen();

            var helper = new AcquireConnectionHelper(this);
            try
            {
                helper.CheckingOutConnection();
                var enteredPool = _poolQueue.Wait(_settings.WaitQueueTimeout, cancellationToken);
                return helper.EnteredPool(enteredPool);
            }
            catch (Exception ex)
            {
                helper.HandleException(ex);
                throw;
            }
            finally
            {
                helper.Finally();
            }
        }