Ejemplo n.º 1
0
 static private void ReceiveCallback(IAsyncResult ar)
 {
     try
     {
         AsynchronousClient state = (AsynchronousClient)ar.AsyncState;
         lock (state.m_Socket)
         {
             int bytesRead = state.m_Socket.EndReceive(ar);
             if (!state.m_Stopped && bytesRead > 0)
             {
                 state.m_ReceiveCallback(state.m_Buffer, bytesRead);
                 state.m_Socket.BeginReceive(state.m_Buffer, 0, state.m_Buffer.GetLength(0), 0, new AsyncCallback(ReceiveCallback), state);
             }
             else
             {
                 state.m_ReceiveDone.Set();
             }
         }
     }
     catch (Exception)
     {
     }
 }