DeflateStream.WriteAsync DeflateStream.WriteAsync DeflateStream.WriteAsync Method

Definition

Overloads

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

Asynchronously writes compressed bytes to the underlying Deflate stream from the specified read-only memory region.

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

Asynchronously writes compressed bytes to the underlying Deflate stream from the specified byte array.

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

Asynchronously writes compressed bytes to the underlying Deflate stream from the specified read-only memory region.

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

Parameters

buffer
ReadOnlyMemory<Byte>

The region of memory to write data from.

cancellationToken
CancellationToken CancellationToken CancellationToken

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

Returns

A task that represents the asynchronous write operation.

Remarks

The WriteAsync method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the async and await keywords in Visual Basic and C#.

Use the CanWrite property to determine whether the current instance supports writing.

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

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

Asynchronously writes compressed bytes to the underlying Deflate stream from the specified byte array.

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

Parameters

array
Byte[]

The buffer that contains the data to compress.

offset
Int32 Int32 Int32

The zero-based byte offset in array from which to begin copying bytes to the Deflate stream.

count
Int32 Int32 Int32

The maximum number of bytes to write.

cancellationToken
CancellationToken CancellationToken CancellationToken

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

Returns

A task that represents the asynchronous write operation.

Remarks

The WriteAsync method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the async and await keywords in Visual Basic and C#.

Use the CanWrite property to determine whether the current instance supports writing.

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

Applies to