c# 调用beginreceive的问题
private static void ReceiveDataCallback(IAsyncResult ar)
{
DataControl state = (DataControl)ar.AsyncState;
try
{
Socket localSocket = state.WorkSocket;
int bytes = localSocket.EndReceive(ar);
if(bytes > 0)
{
state.Data += Encoding.ASCII.GetString(state.DataBuffers, 0, bytes);
localSocket.BeginReceive(state.DataBuffers, 0, state.DataBuffers.Length, 0, new AsyncCallback(ReceiveDataCallback), state);
}
else
{
if(state.Data.Length > 0)
{
state.SetEvent(state.Data.Length);
}
}
}
}
最后一个beginreceive怎么也进不去。 也就是说
else
『
if(state.Data.Length > 0)
{
state.SetEvent(state.Data.Length);
}
}
一直不会被执行
------解决方案--------------------up