public sealed class AsyncResponseStream<TResponse> : IAsyncEnumerable<TResponse>, IAsyncEnumerator<TResponse>, IAsyncDisposableAn adapter from the gRPC stream representation (IAsyncStreamReader<T>) to IAsyncEnumerable<T> and IAsyncEnumerator<T>. Note that GetAsyncEnumerator(CancellationToken) can only be called once per instance due to the "only iterate once" nature of the response stream.
Namespace
Google.Api.Gax.GrpcAssembly
Google.Api.Gax.Grpc.dll
Type Parameter | 
      |
|---|---|
| Name | Description | 
TResponse | 
        The response type.  | 
      
Remarks
This type implements both of the standard asynchronous sequence interfaces for simplicity of use:
- C# 8 users can use  
await foreachbecause it implements IAsyncEnumerable<T> - It's compatible with the System.Linq.Async package for query transformations.
 - Pre-C# 8 users who will be calling MoveNextAsync() and Current directly don't need to call GetAsyncEnumerator(CancellationToken).
 
Properties
Current
public TResponse Current { get; }| Property Value | |
|---|---|
| Type | Description | 
TResponse | 
        |
Methods
DisposeAsync()
public ValueTask DisposeAsync()| Returns | |
|---|---|
| Type | Description | 
ValueTask | 
        |
GetAsyncEnumerator(CancellationToken)
public IAsyncEnumerator<TResponse> GetAsyncEnumerator(CancellationToken cancellationToken = default)Begins iterating over the response stream, using the specified cancellation token. This method can only be called once per instance.
| Parameter | |
|---|---|
| Name | Description | 
cancellationToken | 
        CancellationTokenThe cancellation token to use in subsequent MoveNextAsync() calls.  | 
      
| Returns | |
|---|---|
| Type | Description | 
IAsyncEnumerator | 
        An iterator over the response stream.  | 
      
| Exceptions | |
|---|---|
| Type | Description | 
InvalidOperationException | 
        This method has already been called on this instance.  | 
      
MoveNextAsync()
public ValueTask<bool> MoveNextAsync()Moves to the next item, using the cancellation token configured by GetAsyncEnumerator(CancellationToken).
| Returns | |
|---|---|
| Type | Description | 
ValueTaskbool | 
        |
MoveNextAsync(CancellationToken)
public ValueTask<bool> MoveNextAsync(CancellationToken cancellationToken)Moves to the next item, using the specified cancellation token.
| Parameter | |
|---|---|
| Name | Description | 
cancellationToken | 
        CancellationTokenThe cancellation token to use for this step.  | 
      
| Returns | |
|---|---|
| Type | Description | 
ValueTaskbool | 
        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.  |