예제 #1
0
        public async Task <bool> MoveNext(CancellationToken token)
        {
            using (call.RegisterCancellationCallbackForToken(token))
            {
                var result = await call.ReadMessageAsync().ConfigureAwait(false);

                this.current = result;
                return(result != null);
            }
        }
예제 #2
0
        public async Task <bool> MoveNext(CancellationToken token)
        {
            if (token != CancellationToken.None)
            {
                throw new InvalidOperationException("Cancellation of individual reads is not supported.");
            }
            var result = await call.ReadMessageAsync().ConfigureAwait(false);

            this.current = result;
            return(result != null);
        }
예제 #3
0
        public async Task <bool> MoveNext(CancellationToken token)
        {
            var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable)null;

            using (cancellationTokenRegistration)
            {
                var result = await call.ReadMessageAsync().ConfigureAwait(false);

                this.current = result;
                return(result != null);
            }
        }