Method CompressAsync
CompressAsync(Stream, CancellationToken)
Asynchronously compresses the data in the source stream and returns a new MemoryStreamSlim instance containing the compressed data.
public static Task<MemoryStreamSlim> CompressAsync(Stream source, CancellationToken cancellationToken)
Parameters
sourceStreamThe source stream to compress. This stream must be readable and seekable.
cancellationTokenCancellationTokenThe cancellation token to use for the operation.
Returns
- Task<MemoryStreamSlim>
An awaitable task that completes when the operation is complete and returns a new MemoryStreamSlim instance containing the compressed data from the source stream using the specified compression type. If the source stream is empty, an empty MemoryStreamSlim instance is returned.
CompressAsync(Stream, MemoryStreamBrotliOptions, CancellationToken)
Asynchronously compresses the data in the source stream and returns a new MemoryStreamSlim instance containing the compressed data.
public static Task<MemoryStreamSlim> CompressAsync(Stream source, MemoryStreamBrotliOptions compressionOptions, CancellationToken cancellationToken)
Parameters
sourceStreamThe source stream to compress. This stream must be readable and seekable.
compressionOptionsMemoryStreamBrotliOptionsThe options that control the compression operation. This can be used to specify the compression type, the compression level, and other options. If null, then default options are used.
cancellationTokenCancellationTokenThe cancellation token to use for the operation.
Returns
- Task<MemoryStreamSlim>
An awaitable task that completes when the operation is complete and returns a new MemoryStreamSlim instance containing the compressed data from the source stream using the specified compression type. If the source stream is empty, an empty MemoryStreamSlim instance is returned.
CompressAsync(Stream, Func<MemoryStreamBrotliOptions, MemoryStreamBrotliOptions>, CancellationToken)
Asynchronously compresses the data in the source stream and returns a new MemoryStreamSlim instance containing the compressed data.
public static Task<MemoryStreamSlim> CompressAsync(Stream source, Func<MemoryStreamBrotliOptions, MemoryStreamBrotliOptions> optionsSetup, CancellationToken cancellationToken)
Parameters
sourceStreamThe source stream to compress. This stream must be readable and seekable.
optionsSetupFunc<MemoryStreamBrotliOptions, MemoryStreamBrotliOptions>Delegate to set up options to configure the compression operation.
cancellationTokenCancellationTokenThe cancellation token to use for the operation.
Returns
- Task<MemoryStreamSlim>
An awaitable task that completes when the operation is complete and returns a new MemoryStreamSlim instance containing the compressed data from the source stream using the specified compression type. If the source stream is empty, an empty MemoryStreamSlim instance is returned.
CompressAsync<TState>(Stream, Func<MemoryStreamBrotliOptions, TState, MemoryStreamBrotliOptions>, TState, CancellationToken)
Asynchronously compresses the data in the source stream and returns a new MemoryStreamSlim instance containing the compressed data.
public static Task<MemoryStreamSlim> CompressAsync<TState>(Stream source, Func<MemoryStreamBrotliOptions, TState, MemoryStreamBrotliOptions> optionsSetup, TState setupState, CancellationToken cancellationToken)
Parameters
sourceStreamThe source stream to compress. This stream must be readable and seekable.
optionsSetupFunc<MemoryStreamBrotliOptions, TState, MemoryStreamBrotliOptions>Delegate to set up options to configure the compression operation.
setupStateTStateState object to pass to the options setup delegate. This can be used to pass any type of state information to the delegate and avoid the need for a closure.
cancellationTokenCancellationTokenThe cancellation token to use for the operation.
Returns
- Task<MemoryStreamSlim>
An awaitable task that completes when the operation is complete and returns a new MemoryStreamSlim instance containing the compressed data from the source stream using the specified compression type. If the source stream is empty, an empty MemoryStreamSlim instance is returned.
Type Parameters
TState