Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C# by Eugene ( 15 years ago )
protected virtual MemoryStream ReadResponseBody(Stream source, int length)
  {
   byte[] buffer = new byte[length];
   NetworkReadState state = new NetworkReadState { DataStream = source, BytesLeft = length };
   _resetEvent = new ManualResetEvent(false);
   while (state.BytesLeft > 0)
   {
    _resetEvent.Reset();
    source.BeginRead(buffer, length - state.BytesLeft, state.BytesLeft, ReadBodyCallback, state);
    if (!_resetEvent.WaitOne(Connection.ConnectionTimeout, true))
    {
     source.Close();
     throw new TimeoutException(Messages.Exception_NetworkConnectionIsUnavailable);
    }
   }

   return new MemoryStream(buffer);
  }

 

Revise this Paste

Children: 37757
Your Name: Code Language: