/// <summary> /// Extends BeginRead so that when a state object is not needed, null does not need to be passed. /// <example> /// deflatestream.BeginRead(array, offset, count, asyncCallback); /// </example> /// </summary> public static IAsyncResult BeginRead(this DeflateStream deflatestream, Byte[] array, Int32 offset, Int32 count, AsyncCallback asyncCallback) { if (deflatestream == null) { throw new ArgumentNullException("deflatestream"); } return(deflatestream.BeginRead(array, offset, count, asyncCallback, null)); }
/// <summary> /// Extends BeginRead so that buffer offset of 0 and call to Array.Length are not needed. /// <example> /// deflatestream.BeginRead(array, asyncCallback); /// </example> /// </summary> public static IAsyncResult BeginRead(this DeflateStream deflatestream, Byte[] array, AsyncCallback asyncCallback) { if (deflatestream == null) { throw new ArgumentNullException("deflatestream"); } if (array == null) { throw new ArgumentNullException("array"); } return(deflatestream.BeginRead(array, 0, array.Length, asyncCallback)); }
public void AsyncRead() { DeflateStream cs = new DeflateStream(new MemoryStream(), CompressionMode.Decompress); message = "AsyncRead"; reset.Reset(); IAsyncResult r = cs.BeginRead(new byte[0], 0, 0, new AsyncCallback(ReadCallback), cs); Assert.IsNotNull(r, "IAsyncResult"); if (!reset.WaitOne(timeout, true)) { Assert.Ignore("Timeout"); } Assert.IsNull(message, message); cs.Close(); }
/// <summary>Begins an asynchronous read operation.</summary> /// <returns>An <see cref="T:System.IAsyncResult" /> object that represents the asynchronous read, which could still be pending.</returns> /// <param name="array">The byte array to read the data into.</param> /// <param name="offset">The byte offset in <paramref name="array" /> at which to begin writing data read from the stream.</param> /// <param name="count">The maximum number of bytes to read.</param> /// <param name="asyncCallback">An optional asynchronous callback, to be called when the read is complete.</param> /// <param name="asyncState">A user-provided object that distinguishes this particular asynchronous read request from other requests.</param> /// <exception cref="T:System.IO.IOException">An asynchronous read past the end of the stream was attempted, or a disk error occurred.</exception> /// <exception cref="T:System.ArgumentException">One or more of the arguments is invalid.</exception> /// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed.</exception> /// <exception cref="T:System.NotSupportedException">The current <see cref="T:System.IO.Compression.GZipStream" /> implementation does not support the read operation.</exception> /// <exception cref="T:System.InvalidOperationException">A read operation cannot be performed because the stream is closed.</exception> public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback cback, object state) { return(deflateStream.BeginRead(buffer, offset, count, cback, state)); }