Exemplo n.º 1
0
        private void OnRecieved(IAsyncResult ar)
        {
            ReaderStateObject stateObj = (ReaderStateObject)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();

                int readNum = _socket.EndReceive(ar);
                if (0 == readNum)
                {
                    throw GetClosedException();
                }

                _linesBuilder.PutData(_recvBuffer, readNum, false);
                BuildResponse(stateObj);
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
            catch
            {
                NSTrace.WriteLineError("Non-CLS exception at: " + Environment.StackTrace);
                throw;
            }
        }