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();
            }
        }
Exemplo 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();
            }
        }
Exemplo n.º 3
0
 public async Task <IConnectionHandle> AcquireConnectionAsync(CancellationToken cancellationToken)
 {
     using var helper = new AcquireConnectionHelper(this);
     return(await helper.AcquireConnectionAsync(cancellationToken).ConfigureAwait(false));
 }
Exemplo n.º 4
0
 // public methods
 public IConnectionHandle AcquireConnection(CancellationToken cancellationToken)
 {
     using var helper = new AcquireConnectionHelper(this);
     return(helper.AcquireConnection(cancellationToken));
 }
        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();
            }
        }