public ReadDataAsyncResult(SizedTcpBaseChannel channel, AsyncCallback callback, object state) : base(callback, state) { this.channel = channel; bool success = false; try { IAsyncResult drainLengthResult = channel.BeginSocketReceiveBytes(4, false, OnDrainLength, this); if (drainLengthResult.CompletedSynchronously) { if (CompleteDrainLength(drainLengthResult)) { base.Complete(true); } } success = true; } catch (CommunicationException e) { base.Complete(true, e); } finally { if (!success) { this.Cleanup(); } } }
public SocketReceiveAsyncResult(int size, bool throwOnEmpty, SizedTcpBaseChannel channel, AsyncCallback callback, object state) : base(callback, state) { this.size = size; this.channel = channel; this.throwOnEmpty = throwOnEmpty; this.bytesReadTotal = 0; this.buffer = channel.bufferManager.TakeBuffer(size); bool success = false; try { IAsyncResult socketReceiveResult = channel.BeginSocketReceive(this.buffer, bytesReadTotal, size, OnReadBytes, this); if (socketReceiveResult.CompletedSynchronously) { if (CompleteReadBytes(socketReceiveResult)) { base.Complete(true); } } success = true; } finally { if (!success) { this.Cleanup(); } } }
public SocketSendAsyncResult(ArraySegment <byte> buffer, SizedTcpBaseChannel channel, AsyncCallback callback, object state) : base(callback, state) { this.channel = channel; this.buffer = buffer; this.StartSending(); }
public SocketSendAsyncResult(ArraySegment<byte> buffer, SizedTcpBaseChannel channel, AsyncCallback callback, object state) : base(callback, state) { this.channel = channel; this.buffer = buffer; this.StartSending(); }