Method WriteAsync
- Namespace
- DotNetBrowser.Net
- Assembly
- DotNetBrowser.dll
WriteAsync(UrlRequestJob, Stream, CancellationToken, int)
Reads all bytes from stream and writes them to the URL request job asynchronously.
public static Task WriteAsync(this UrlRequestJob job, Stream stream, CancellationToken cancellationToken = default, int bufferSize = 81920)
Parameters
jobUrlRequestJobThe URL request job to write the data to.
streamStreamThe stream to read the data from.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
bufferSizeintThe size of the buffer used to read the stream. Must be greater than zero.
Returns
Remarks
The stream is read in chunks to avoid buffering the entire content in memory.
The calling thread is released while waiting for each chunk to be sent to the
browser engine, making this method suitable for use inside Task.Run or
async handlers.
After all data is written, call Complete() or Fail() to finish the request.
Exceptions
- ArgumentNullException
joborstreamisnull.- ArgumentOutOfRangeException
bufferSizeis less than or equal to zero, or greater than MaxValue - 56.