ערוך

שתף באמצעות


NegotiateStream.WriteAsync Method

Definition

Overloads

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Write asynchronously the specified number of Bytes to the underlying stream.

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Write asynchronously the specified number of Bytes to the underlying stream.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

Write asynchronously the specified number of Bytes to the underlying stream.

public override System.Threading.Tasks.ValueTask WriteAsync (ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
override this.WriteAsync : ReadOnlyMemory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Overrides Function WriteAsync (buffer As ReadOnlyMemory(Of Byte), Optional cancellationToken As CancellationToken = Nothing) As ValueTask

Parameters

buffer
ReadOnlyMemory<Byte>

A region of memory that contains the data to write to the NegotiateStream.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

A ValueTask that represents the asynchronous read operation.

Exceptions

This object has been closed.

Authentication has not occurred.

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

Remarks

If encryption, signing, or encryption and signing are enabled, this method reads the data from buffer, encrypts, signs, or encrypts and signs it, and transmits it using the underlying stream. If no security services such as data encryption or signing are in use, this method invokes WriteAsync on the underlying stream.

You cannot call this method until you have successfully authenticated. To authenticate, call one of the AuthenticateAsClient, AuthenticateAsClientAsync, BeginAuthenticateAsClient, AuthenticateAsServer, AuthenticateAsServerAsync, or BeginAuthenticateAsServer methods.

Applies to

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

Write asynchronously the specified number of Bytes to the underlying stream.

public:
 override System::Threading::Tasks::Task ^ WriteAsync(cli::array <System::Byte> ^ buffer, int offset, int count, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task WriteAsync (byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken);
override this.WriteAsync : byte[] * int * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overrides Function WriteAsync (buffer As Byte(), offset As Integer, count As Integer, cancellationToken As CancellationToken) As Task

Parameters

buffer
Byte[]

A Byte array that supplies the bytes written to the stream.

offset
Int32

An Int32 containing the zero-based location in buffer at which to begin reading bytes to be written to the stream.

count
Int32

A Int32 containing the number of bytes to read from buffer.

cancellationToken
CancellationToken

Returns

A Task that represents the asynchronous read operation.

Exceptions

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

Remarks

If encryption, signing, or encryption and signing are enabled, this method reads the data from buffer, encrypts, signs, or encrypts and signs it, and transmits it using the underlying stream. If no security services such as data encryption or signing are in use, this method invokes WriteAsync on the underlying stream.

You cannot call this method until you have successfully authenticated. To authenticate, call one of the AuthenticateAsClient, AuthenticateAsClientAsync, BeginAuthenticateAsClient, AuthenticateAsServer, AuthenticateAsServerAsync, or BeginAuthenticateAsServer methods.

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 Write(Byte[], Int32, Int32).

Applies to