public virtual int EndRead (IAsyncResult asyncResult)
{
if (asyncResult == null)
throw new ArgumentNullException ("asyncResult");
StreamAsyncResult result = asyncResult as StreamAsyncResult;
if (result == null || result.NBytes == -1)
throw new ArgumentException ("Invalid IAsyncResult", "asyncResult");
if (result.Done)
throw new InvalidOperationException ("EndRead already called.");
result.Done = true;
if (result.Exception != null)
throw result.Exception;
return result.NBytes;
}