Click or drag to resize

BsonStreamAdapterWriteAsync Method (Byte, Int32, Int32, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

Namespace:  MongoDB.Bson.IO
Assembly:  MongoDB.Bson (in MongoDB.Bson.dll) Version: 2.18.0+554c799eb1ec8dd732f16c739387f6664df1ba7a
Syntax
public override Task WriteAsync(
	byte[] buffer,
	int offset,
	int count,
	CancellationToken cancellationToken
)

Parameters

buffer
Type: SystemByte
The buffer to write data from.
offset
Type: SystemInt32
The zero-based byte offset in buffer from which to begin copying bytes to the stream.
count
Type: SystemInt32
The maximum number of bytes to write.
cancellationToken
Type: System.ThreadingCancellationToken
The token to monitor for cancellation requests. The default value is None.

Return Value

Type: Task
A task that represents the asynchronous write operation.
Exceptions
ExceptionCondition
ArgumentNullExceptionbuffer is .
ArgumentOutOfRangeExceptionoffset or count is negative.
ArgumentExceptionThe sum of offset and count is larger than the buffer length.
NotSupportedExceptionThe stream does not support writing.
ObjectDisposedExceptionThe stream has been disposed.
InvalidOperationExceptionThe stream is currently in use by a previous write operation.
See Also