/// <summary> /// Extends BeginRead so that when a state object is not needed, null does not need to be passed. /// <example> /// gzipstream.BeginRead(array, offset, count, asyncCallback); /// </example> /// </summary> public static IAsyncResult BeginRead(this GZipStream gzipstream, Byte[] array, Int32 offset, Int32 count, AsyncCallback asyncCallback) { if (gzipstream == null) { throw new ArgumentNullException("gzipstream"); } return(gzipstream.BeginRead(array, offset, count, asyncCallback, null)); }
/// <summary> /// Extends BeginRead so that buffer offset of 0 and call to Array.Length are not needed. /// <example> /// gzipstream.BeginRead(array, asyncCallback); /// </example> /// </summary> public static IAsyncResult BeginRead(this GZipStream gzipstream, Byte[] array, AsyncCallback asyncCallback) { if (gzipstream == null) { throw new ArgumentNullException("gzipstream"); } if (array == null) { throw new ArgumentNullException("array"); } return(gzipstream.BeginRead(array, 0, array.Length, asyncCallback)); }
public void AsyncRead() { GZipStream cs = new GZipStream(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(); }
private void startStreamAsyncRead() { byte[] buffer = new byte[1000000]; if (this.isConnected() == false) { System.Diagnostics.Debug.WriteLine("isconnected is false"); this.OnServerDisconnected(new ServerEventArgs(this.tcpClient)); this.Disconnect(); return; } if (useExplicitStreams) { AsyncCallback networkReadCallback = new AsyncCallback(dataReceivedSsh); sshStreamRead.BeginRead(buffer, 0, 100000, networkReadCallback, buffer); } else { if (!tcpStream.CanRead) { return; /* program probably died */ } AsyncCallback networkReadCallback = new AsyncCallback(dataReceived); try { if (tcpStreamGzipRead != null) { tcpStreamGzipRead.BeginRead(buffer, 0, 1000000, networkReadCallback, buffer); } else { tcpStream.BeginRead(buffer, 0, 1000000, networkReadCallback, buffer); } } catch (Exception) { MessageBox.Show("Disconnected?"); } // tcpStream.Read(buffer, p, p_3); } }
public override IAsyncResult BeginRead(byte[] array, int offset, int count, AsyncCallback asyncCallback, object asyncState) { return(_stream.BeginRead(array, offset, count, asyncCallback, asyncState)); }