Class AsyncResponseStream<TResponse>
An adapter from the gRPC stream representation (IAsyncStreamReader<T>) to System.Collections.Generic.IAsyncEnumerable<T> and System.Collections.Generic.IAsyncEnumerator<T>. Note that GetAsyncEnumerator(CancellationToken) can only be called once per instance due to the "only iterate once" nature of the response stream.
Inheritance
Implements
Inherited Members
Namespace: Google.Api.Gax.Grpc
Assembly: Google.Api.Gax.Grpc.dll
Syntax
public sealed class AsyncResponseStream<TResponse> : IAsyncEnumerable<TResponse>, IAsyncEnumerator<TResponse>, IAsyncDisposable
Type Parameters
Name | Description |
---|---|
TResponse | The response type. |
Remarks
This type implements both of the standard asynchronous sequence interfaces for simplicity of use:
Properties
Current
Declaration
public TResponse Current { get; }
Property Value
Type | Description |
---|---|
TResponse |
Implements
Methods
DisposeAsync()
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask |
Implements
GetAsyncEnumerator(CancellationToken)
Begins iterating over the response stream, using the specified cancellation token. This method can only be called once per instance.
Declaration
public IAsyncEnumerator<TResponse> GetAsyncEnumerator(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The cancellation token to use in subsequent MoveNextAsync() calls. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerator<TResponse> | An iterator over the response stream. |
Implements
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | This method has already been called on this instance. |
MoveNextAsync()
Moves to the next item, using the cancellation token configured by GetAsyncEnumerator(CancellationToken).
Declaration
public ValueTask<bool> MoveNextAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Boolean> |
Implements
MoveNextAsync(CancellationToken)
Moves to the next item, using the specified cancellation token.
Declaration
public ValueTask<bool> MoveNextAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The cancellation token to use for this step. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Boolean> | A task that will complete with a result of true if the enumerator was successfully advanced to the next element, or false if the enumerator has passed the end of the collection. |