private void ReceiveCallback( IAsyncResult ar )
{
// Retrieve the state object
// from the asynchronous state object.
if (mClient!=null)
{
StateObject state = (StateObject) ar.AsyncState;
// Read data from the remote device.
int bytesRead = mClient.EndReceive(ar);
if (bytesRead > 0)
{
byte[] data = new Byte[bytesRead];
CopyTo(state.buffer, data, 0, data.Length);
this.ParseIt(data);
mClient.BeginReceive(state.buffer,0,StateObject.BufferSize,0,
new AsyncCallback(ReceiveCallback), state);
mReceiveDone.Set();
}
}
}