Esempio n. 1
0
 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));
     }
 }
Esempio n. 2
0
        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));
            }
        }