private void Read(IOState state) { try { networkStream.BeginRead(state.Data, 0, state.Size, EndOrContinueRead, state); } catch (Exception ex) { Received?.Invoke(this, new ReceivedEventArgs(ex, this, state.Data)); } }
private void EndWrite(IAsyncResult ar) { IOState state = ar.AsyncState as WriteIOState; try { networkStream.EndWrite(ar); state.AdvancePosition(state.Size); if (state.NotifySuccess) { Sent?.Invoke(this, new SentEventArgs(this, state.Data)); } } catch (Exception ex) { Sent?.Invoke(this, new SentEventArgs(ex, this, state.Data)); } }