MessageHandlerBase.ReadAsync(CancellationToken) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Reads a distinct and complete message from the transport, waiting for one if necessary.
public System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage> ReadAsync (System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage?> ReadAsync (System.Threading.CancellationToken cancellationToken);
abstract member ReadAsync : System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage>
override this.ReadAsync : System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage>
Public Function ReadAsync (cancellationToken As CancellationToken) As ValueTask(Of JsonRpcMessage)
Parameters
- cancellationToken
- CancellationToken
A token to cancel the read request.
Returns
The received message, or null
if the underlying transport ends before beginning another message.
Implements
Exceptions
Thrown when CanRead returns false
.
Thrown if the transport ends while reading a message.
Thrown if cancellationToken
is canceled before a new message is received.
Remarks
Implementations may assume this method is never called before any async result from a prior call to this method has completed.