コード例 #1
0
        public Task WriteStatusAsync(Status status, Metadata trailers)
        {
            var taskSource = new AsyncCompletionTaskSource <object>();

            call.StartSendStatusFromServer(status, trailers, taskSource.CompletionDelegate);
            return(taskSource.Task);
        }
コード例 #2
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();
        }
コード例 #3
0
        public void StartCall(string methodName, CallSafeHandle call, CompletionQueueSafeHandle cq)
        {
            // We don't care about the payload type here.
            var asyncCall = new AsyncCallServer <byte[], byte[]>(
                (payload) => payload, (payload) => payload);

            asyncCall.Initialize(call);

            var finishedTask = asyncCall.ServerSideCallAsync(new NullObserver <byte[]>());

            // TODO: check result of the completion status.
            asyncCall.StartSendStatusFromServer(new Status(StatusCode.Unimplemented, "No such method."), new AsyncCompletionDelegate((error) => { }));

            finishedTask.Wait();
        }