Example #1
0
        public Task <TResponse> ReadNext()
        {
            var taskSource = new AsyncCompletionTaskSource <TResponse>();

            call.StartReadMessage(taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Example #2
0
        public async Task <bool> MoveNext(CancellationToken token)
        {
            if (token != CancellationToken.None)
            {
                throw new InvalidOperationException("Cancellation of individual reads is not supported.");
            }
            var taskSource = new AsyncCompletionTaskSource <TResponse>();

            call.StartReadMessage(taskSource.CompletionDelegate);
            var result = await taskSource.Task;

            this.current = result;
            return(result != null);
        }
Example #3
0
        public async Task <bool> MoveNext(CancellationToken token)
        {
            if (token != CancellationToken.None)
            {
                throw new InvalidOperationException("Cancellation of individual reads is not supported.");
            }
            var taskSource = new AsyncCompletionTaskSource <TResponse>();

            call.StartReadMessage(taskSource.CompletionDelegate);
            var result = await taskSource.Task.ConfigureAwait(false);

            this.current = result;

            if (result == null)
            {
                await call.StreamingCallFinishedTask.ConfigureAwait(false);

                return(false);
            }
            return(true);
        }