FlushAsync() public method

public FlushAsync ( CancellationToken cancellationToken ) : System.Threading.Task
cancellationToken System.Threading.CancellationToken
return System.Threading.Task
示例#1
0
        public void Precancellation()
        {
            var ms = new MemoryStream();

            using (Stream compressor = new DeflateStream(ms, CompressionMode.Compress, leaveOpen: true))
            {
                Assert.True(compressor.WriteAsync(new byte[1], 0, 1, new CancellationToken(true)).IsCanceled);
                Assert.True(compressor.FlushAsync(new CancellationToken(true)).IsCanceled);
            }
            using (Stream decompressor = CreateStream(ms, CompressionMode.Decompress, leaveOpen: true))
            {
                Assert.True(decompressor.ReadAsync(new byte[1], 0, 1, new CancellationToken(true)).IsCanceled);
            }
        }
示例#2
0
        public static async Task FlushAsyncFailsAfterDispose()
        {

            var ms = new MemoryStream();
            var ds = new DeflateStream(ms, CompressionMode.Compress);
            ds.Dispose();

            await Assert.ThrowsAsync<ObjectDisposedException>(async () =>
            {
                await ds.FlushAsync();
            });
        }
示例#3
0
 public override Task FlushAsync(CancellationToken cancellationToken)
 {
     CheckDeflateStream();
     return(_deflateStream.FlushAsync(cancellationToken));
 }
示例#4
0
        public static async Task Flush()
        {
            var ms = new MemoryStream();
            var ds = new DeflateStream(ms, CompressionMode.Compress);
            ds.Flush();
            await ds.FlushAsync();

            // Just ensuring Flush doesn't throw
        }