public override async Task <Envelope> ReceiveAsync(CancellationToken cancellationToken)
        {
            EnsureOpen("receive");

            try
            {
                return(await _envelopePipe.ReceiveAsync(cancellationToken).ConfigureAwait(false));
            }
            catch (InvalidOperationException)
            {
                await CloseWithTimeoutAsync().ConfigureAwait(false);

                throw;
            }
        }
示例#2
0
        /// <summary>
        /// Reads one envelope from the pipe.
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public override async Task <Envelope> ReceiveAsync(CancellationToken cancellationToken)
        {
            if (_readTaskWaiting)
            {
                // Signals the pipe stream read task to proceed
                await _readSynchronizationQueue.SendAsync(null, cancellationToken).ConfigureAwait(false);
            }

            try
            {
                var envelope = await _envelopePipe.ReceiveAsync(cancellationToken).ConfigureAwait(false);

                UpdateSessionNegotiated(envelope);
                return(envelope);
            }
            catch (InvalidOperationException)
            {
                await CloseWithTimeoutAsync();

                throw;
            }
        }