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
source
StreamThe source stream to compress. This stream must be readable and seekable.
cancellationToken
CancellationTokenThe 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, MemoryStreamGZipOptions, 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, MemoryStreamGZipOptions compressionOptions, CancellationToken cancellationToken)
Parameters
source
StreamThe source stream to compress. This stream must be readable and seekable.
compressionOptions
MemoryStreamGZipOptionsThe 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.
cancellationToken
CancellationTokenThe 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<MemoryStreamGZipOptions, MemoryStreamGZipOptions>, 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<MemoryStreamGZipOptions, MemoryStreamGZipOptions> optionsSetup, CancellationToken cancellationToken)
Parameters
source
StreamThe source stream to compress. This stream must be readable and seekable.
optionsSetup
Func<MemoryStreamGZipOptions, MemoryStreamGZipOptions>Delegate to set up options to configure the compression operation.
cancellationToken
CancellationTokenThe 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<MemoryStreamGZipOptions, TState, MemoryStreamGZipOptions>, 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<MemoryStreamGZipOptions, TState, MemoryStreamGZipOptions> optionsSetup, TState setupState, CancellationToken cancellationToken)
Parameters
source
StreamThe source stream to compress. This stream must be readable and seekable.
optionsSetup
Func<MemoryStreamGZipOptions, TState, MemoryStreamGZipOptions>Delegate to set up options to configure the compression operation.
setupState
TStateState 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.
cancellationToken
CancellationTokenThe 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