Пример #1
0
 private async Task <TResult> ExecuteProtocolAsync <TResult>(IWireProtocol <TResult> protocol, CancellationToken cancellationToken)
 {
     try
     {
         return(await protocol.ExecuteAsync(_connection, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception ex)
     {
         _server.HandleChannelException(_connection, ex);
         throw;
     }
 }
Пример #2
0
        public static async Task <TResult> ExecuteAsync <TResult>(
            this IWireProtocol <TResult> protocol,
            IConnectionSource connectionSource,
            TimeSpan timeout = default(TimeSpan),
            CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(protocol, "protocol");
            var slidingTimeout = new SlidingTimeout(timeout);

            using (var connection = await connectionSource.GetConnectionAsync(slidingTimeout, cancellationToken))
            {
                return(await protocol.ExecuteAsync(connection, slidingTimeout, cancellationToken));
            }
        }