public sealed class AsyncStreamAdapter<T> : IAsyncStreamReader<T>Simple adapter to allow an IAsyncEnumerator<T> to be used as a gRPC IAsyncStreamReader<T>. Note that cancellation is not fully supported, due to differences between the two interfaces.
Implements
IAsyncStreamReaderNamespace
Google.Api.Gax.Grpc.TestingAssembly
Google.Api.Gax.Grpc.Testing.dll
Type Parameter |
|
|---|---|
| Name | Description |
T |
The element type. |
Constructors
AsyncStreamAdapter(IAsyncEnumerator<T>)
public AsyncStreamAdapter(IAsyncEnumerator<T> enumerator)Wraps the given async enumerator as an async stream reader.
| Parameter | |
|---|---|
| Name | Description |
enumerator |
IAsyncEnumeratorThe enumerator to wrap |
Properties
Current
public T Current { get; }Gets the current element in the iteration.
| Property Value | |
|---|---|
| Type | Description |
T |
|
Methods
MoveNext(CancellationToken)
public Task<bool> MoveNext(CancellationToken cancellationToken)Advances the reader to the next element in the sequence, returning the result asynchronously.
| Parameter | |
|---|---|
| Name | Description |
cancellationToken |
CancellationTokenCancellation token that can be used to cancel the operation. |
| Returns | |
|---|---|
| Type | Description |
Taskbool |
Task containing the result of the operation: true if the reader was successfully advanced to the next element; false if the reader has passed the end of the sequence. |