public override int EndRead(IAsyncResult asyncResult) { int read = _stream.EndRead(asyncResult); _position += read; return(read); }
// async tests (for stack propagation) private void ReadCallback(IAsyncResult ar) { GZipStream s = (GZipStream)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(); } }
void dataReceived(IAsyncResult i) { byte[] buffer = (byte[])i.AsyncState; int nBytes = 0; try { if (tcpStreamGzipRead != null) { nBytes = tcpStreamGzipRead.EndRead(i); } else { nBytes = tcpStream.EndRead(i); } if (nBytes != 0) { processBytes(buffer, nBytes); } } catch (Exception Ex) { if (Ex is InvalidOperationException) { // MessageBox.Show( Ex.ToString(),"Exception reading data from server"); if (this.appwin != null) { this.appwin.pleaseClose(); } } else { Console.WriteLine(Ex.Message); // Silently carry on ..... } } startStreamAsyncRead(); }