// async tests (for stack propagation) private void ReadCallback(IAsyncResult ar) { DeflateStream s = (DeflateStream)ar.AsyncState; s.EndRead(ar); try { // can we do something bad here ? Assert.IsNotNull(Environment.GetEnvironmentVariable("USERNAME")); message = "Expected a SecurityException"; } catch (SecurityException) { message = null; reset.Set(); } catch (Exception e) { message = e.ToString(); } }
/// <summary>Waits for the pending asynchronous read to complete.</summary> /// <returns>The number of bytes read from the stream, between zero (0) and the number of bytes you requested. <see cref="T:System.IO.Compression.GZipStream" /> returns zero (0) only at the end of the stream; otherwise, it blocks until at least one byte is available.</returns> /// <param name="asyncResult">The reference to the pending asynchronous request to finish.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="asyncResult" /> is null.</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="asyncResult" /> did not originate from a <see cref="M:System.IO.Compression.DeflateStream.BeginRead(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)" /> method on the current stream.</exception> /// <exception cref="T:System.InvalidOperationException">The end operation cannot be performed because the stream is closed.</exception> public override int EndRead(IAsyncResult async_result) { return(deflateStream.EndRead(async_result)); }