Class AsyncUnaryCall<TResponse>

public sealed class AsyncUnaryCall<TResponse> : IDisposable

Return type for single request - single response call.

Inheritance

Object > AsyncUnaryCall<TResponse>

Namespace

Grpc.Core

Assembly

Grpc.Core.Api.dll

Type Parameter

NameDescription
TResponse

Response message type for this call.

Constructors

AsyncUnaryCall(Task<TResponse>, Func<Object, Task<Metadata>>, Func<Object, Status>, Func<Object, Metadata>, Action<Object>, Object)

public AsyncUnaryCall(Task<TResponse> responseAsync, Func<object, Task<Metadata>> responseHeadersAsync, Func<object, Status> getStatusFunc, Func<object, Metadata> getTrailersFunc, Action<object> disposeAction, object state)

Creates a new AsyncUnaryCall object with the specified properties.

Parameters
TypeNameDescription
Task<TResponse>responseAsync

The response of the asynchronous call.

Func<Object, Task<Metadata>>responseHeadersAsync

Response headers of the asynchronous call.

Func<Object, Status>getStatusFunc

Delegate returning the status of the call.

Func<Object, Metadata>getTrailersFunc

Delegate returning the trailing metadata of the call.

Action<Object>disposeAction

Delegate to invoke when Dispose is called on the call object.

Objectstate

State object for use with the callback parameters.

AsyncUnaryCall(Task<TResponse>, Task<Metadata>, Func<Status>, Func<Metadata>, Action)

public AsyncUnaryCall(Task<TResponse> responseAsync, Task<Metadata> responseHeadersAsync, Func<Status> getStatusFunc, Func<Metadata> getTrailersFunc, Action disposeAction)

Creates a new AsyncUnaryCall object with the specified properties.

Parameters
TypeNameDescription
Task<TResponse>responseAsync

The response of the asynchronous call.

Task<Metadata>responseHeadersAsync

Response headers of the asynchronous call.

Func<Status>getStatusFunc

Delegate returning the status of the call.

Func<Metadata>getTrailersFunc

Delegate returning the trailing metadata of the call.

ActiondisposeAction

Delegate to invoke when Dispose is called on the call object.

Properties

ResponseAsync

public Task<TResponse> ResponseAsync { get; }

Asynchronous call result.

Property Value
TypeDescription
Task<TResponse>

ResponseHeadersAsync

public Task<Metadata> ResponseHeadersAsync { get; }

Asynchronous access to response headers.

Property Value
TypeDescription
Task<Metadata>

Methods

Dispose()

public void Dispose()

Provides means to cleanup after the call. If the call has already finished normally (request stream has been completed and call result has been received), doesn't do anything. Otherwise, requests cancellation of the call which should terminate all pending async operations associated with the call. As a result, all resources being used by the call should be released eventually.

Remarks

Normally, there is no need for you to dispose the call unless you want to utilize the "Cancel" semantics of invoking Dispose.

GetAwaiter()

public TaskAwaiter<TResponse> GetAwaiter()

Allows awaiting this object directly.

Returns
TypeDescription
TaskAwaiter<TResponse>

GetStatus()

public Status GetStatus()

Gets the call status if the call has already finished. Throws InvalidOperationException otherwise.

Returns
TypeDescription
Status

GetTrailers()

public Metadata GetTrailers()

Gets the call trailing metadata if the call has already finished. Throws InvalidOperationException otherwise.

Returns
TypeDescription
Metadata