Пример #1
0
        public Task <TResponse> ReadNext()
        {
            var taskSource = new AsyncCompletionTaskSource <TResponse>();

            call.StartReadMessage(taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Пример #2
0
        public Task WriteResponseHeadersAsync(Metadata responseHeaders)
        {
            var taskSource = new AsyncCompletionTaskSource <object>();

            call.StartSendInitialMetadata(responseHeaders, taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Пример #3
0
        public Task WriteAsync(TResponse message)
        {
            var taskSource = new AsyncCompletionTaskSource <object>();

            call.StartSendMessage(message, GetWriteFlags(), taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Пример #4
0
        public Task WriteStatusAsync(Status status, Metadata trailers)
        {
            var taskSource = new AsyncCompletionTaskSource <object>();

            call.StartSendStatusFromServer(status, trailers, taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Пример #5
0
        public Task Close()
        {
            var taskSource = new AsyncCompletionTaskSource <object>();

            call.StartSendCloseFromClient(taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Пример #6
0
        public Task Write(TRequest message)
        {
            var taskSource = new AsyncCompletionTaskSource <object>();

            call.StartSendMessage(message, taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
Пример #7
0
        public void OnNext(TResponse value)
        {
            var taskSource = new AsyncCompletionTaskSource();

            call.StartSendMessage(value, taskSource.CompletionDelegate);
            // TODO: how bad is the Wait here?
            taskSource.Task.Wait();
        }
Пример #8
0
        public void OnCompleted()
        {
            var taskSource = new AsyncCompletionTaskSource();

            call.StartSendStatusFromServer(new Status(StatusCode.OK, ""), taskSource.CompletionDelegate);
            // TODO: how bad is the Wait here?
            taskSource.Task.Wait();
        }
Пример #9
0
        public void OnCompleted()
        {
            var taskSource = new AsyncCompletionTaskSource();

            call.StartSendCloseFromClient(taskSource.CompletionDelegate);
            // TODO: how bad is the Wait here?
            taskSource.Task.Wait();
        }
Пример #10
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 <TRequest>();

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

            this.current = result;
            return(result != null);
        }
Пример #11
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;

            if (result == null)
            {
                await call.StreamingCallFinishedTask;
                return(false);
            }
            return(true);
        }