private static void ReadCallback(object state) { ConnectionModeReader connectionModeReader = (ConnectionModeReader)state; bool flag = false; Exception exception = null; try { if (connectionModeReader.GetReadResult()) { flag = connectionModeReader.ContinueReading(); } } catch (Exception exception2) { Exception exception1 = exception2; if (Fx.IsFatal(exception1)) { throw; } flag = true; exception = exception1; } if (flag) { connectionModeReader.Complete(exception); } }
private bool ContinueReading() { int num; string str; while (true) { if (this.size == 0) { if (ConnectionModeReader.readCallback == null) { ConnectionModeReader.readCallback = new WaitCallback(ConnectionModeReader.ReadCallback); } if (base.Connection.BeginRead(0, base.Connection.AsyncReadBufferSize, this.GetRemainingTimeout(), ConnectionModeReader.readCallback, this) == AsyncReadResult.Queued) { break; } if (!this.GetReadResult()) { return(false); } } do { try { num = this.decoder.Decode(this.buffer, this.offset, this.size); } catch (CommunicationException communicationException) { if (FramingEncodingString.TryGetFaultString(communicationException, out str)) { byte[] numArray = new byte[128]; InitialServerConnectionReader.SendFault(base.Connection, str, numArray, this.GetRemainingTimeout(), base.MaxViaSize + base.MaxContentTypeSize); base.Close(this.GetRemainingTimeout()); } throw; } if (num > 0) { ConnectionModeReader connectionModeReader = this; connectionModeReader.offset = connectionModeReader.offset + num; ConnectionModeReader connectionModeReader1 = this; connectionModeReader1.size = connectionModeReader1.size - num; } if (this.decoder.CurrentState != ServerModeDecoder.State.Done) { continue; } return(true); }while (this.size != 0); } return(false); }