Redigera

Dela via


HashAlgorithm.ComputeHashAsync(Stream, CancellationToken) Method

Definition

Asynchronously computes the hash value for the specified Stream object.

public System.Threading.Tasks.Task<byte[]> ComputeHashAsync (System.IO.Stream inputStream, System.Threading.CancellationToken cancellationToken = default);
member this.ComputeHashAsync : System.IO.Stream * System.Threading.CancellationToken -> System.Threading.Tasks.Task<byte[]>
Public Function ComputeHashAsync (inputStream As Stream, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Byte())

Parameters

inputStream
Stream

The input to compute the hash code for.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

Task<Byte[]>

A task that represents the asynchronous compute hash operation and wraps the computed hash code.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ComputeHash(Stream).

Applies to