public override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, Object state) {
if (buffer==null) {
throw new ArgumentNullException("buffer");
}
if (offset<0 || offset>buffer.Length) {
throw new ArgumentOutOfRangeException("offset");
}
if (size<0 || size>buffer.Length-offset) {
throw new ArgumentOutOfRangeException("size");
}
try{
return base.BeginRead(buffer, offset, size, callback, state);
}
catch(Exception e){
try{
if (NclUtilities.IsFatal(e)) throw;
if(e is System.IO.InvalidDataException || e is InvalidOperationException || e is IndexOutOfRangeException){
Close();
}
}
catch{
}
throw e;
}
}