UnmanagedMemoryStream.WriteAsync UnmanagedMemoryStream.WriteAsync UnmanagedMemoryStream.WriteAsync Method

定義

多載

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

以非同步方式將位元組範圍寫入至目前的資料流、依寫入的位元組數將此資料流中目前位置往前移,並監視取消要求。Asynchronously writes a span of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

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

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

以非同步方式將位元組範圍寫入至目前的資料流、依寫入的位元組數將此資料流中目前位置往前移,並監視取消要求。Asynchronously writes a span of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

public override System.Threading.Tasks.ValueTask WriteAsync (ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = null);
override this.WriteAsync : ReadOnlyMemory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask

參數

buffer
ReadOnlyMemory<Byte>

寫入資料的來源緩衝區。The buffer to write data from.

cancellationToken
CancellationToken CancellationToken CancellationToken

用來監視是否有取消要求的語彙基元。The token to monitor for cancellation requests. 預設值為 NoneThe default value is None.

傳回

表示非同步寫入作業的工作。A task that represents the asynchronous write operation.

備註

如果在寫入作業期間發生例外狀況, 則會將它設定為Task.Exception所傳回工作之屬性的。If an exception occurs during the write operation, it will be set as the Task.Exception of the property of the returned task.

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

public:
 override System::Threading::Tasks::Task ^ WriteAsync(cli::array <System::Byte> ^ buffer, int offset, int count, System::Threading::CancellationToken cancellationToken);
[System.Runtime.InteropServices.ComVisible(false)]
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

參數

buffer
Byte[]

寫入資料的來源緩衝區。The buffer to write data from.

offset
Int32 Int32 Int32

buffer 中以零起始的位元組位移,要從其中開始將位元組複製至資料流。The zero-based byte offset in buffer from which to begin copying bytes to the stream.

count
Int32 Int32 Int32

寫入的最大位元組數。The maximum number of bytes to write.

cancellationToken
CancellationToken CancellationToken CancellationToken

用來監視是否有取消要求的語彙基元。The token to monitor for cancellation requests. 預設值為 NoneThe default value is None.

傳回

表示非同步寫入作業的工作。A task that represents the asynchronous write operation.

備註

如果在寫入作業期間發生例外狀況, 則會將它設定為Task.Exception所傳回工作之屬性的。If an exception occurs during the write operation, it will be set as the Task.Exception of the property of the returned task.

適用於