Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CryptoStream::WriteAsync Method (array<Byte>^, Int32, Int32, CancellationToken)

.NET Framework (current version)
 

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

Namespace:   System.Security.Cryptography
Assembly:  mscorlib (in mscorlib.dll)

public:
virtual Task^ WriteAsync(
	array<unsigned char>^ buffer,
	int offset,
	int count,
	CancellationToken cancellationToken
) override

Parameters

buffer
Type: array<System::Byte>^

The buffer to write data from.

offset
Type: System::Int32

The zero-based byte offset in buffer from which to begin writing bytes to the stream.

count
Type: System::Int32

The maximum number of bytes to write.

cancellationToken
Type: System.Threading::CancellationToken

The token to monitor for cancellation requests. The default value is None.

Return Value

Type: System.Threading.Tasks::Task^

A task that represents the asynchronous write operation.

Exception Condition
ArgumentNullException

buffer is null.

ArgumentOutOfRangeException

offset or count is negative.

ArgumentException

The sum of offset and count is larger than the buffer length.

NotSupportedException

The stream does not support writing.

ObjectDisposedException

The stream has been disposed.

InvalidOperationException

The stream is currently in use by a previous write operation.

You must preface your call to WriteAsync with the await (C#) or Await (Visual Basic) operator to suspend execution of the method until the task is complete. For more information, see Asynchronous Programming with Async and Await (C# and Visual Basic).

If the operation is canceled before it completes, the returned task contains the Canceled value for the Status property.

.NET Framework
Available since 4.5
Return to top
Show:
© 2017 Microsoft