public async Task <bool> MoveNext(CancellationToken token) { using (call.RegisterCancellationCallbackForToken(token)) { var result = await call.ReadMessageAsync().ConfigureAwait(false); this.current = result; return(result != null); } }
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); }
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); } }