未从此类上对应的异步方法中返回 IAsyncResult 对象。(分全部都加上了,求高手解惑)
未从此类上对应的异步方法中返回 IAsyncResult 对象 用socket异步方式接收返回信息时,会出现如题所示的异常,那位大虾知道是怎么引起的?
client.BeginReceive(MsgBuffer, 0, MsgBuffer.Length, 0, new AsyncCallback(ReceiveCallBack0), null);
private void ReceiveCallBack0(IAsyncResult AR)
{
try
{
int REnd = client.EndReceive(AR);
if (REnd == 0)
{
if (client.Connected)
{
client.Shutdown(SocketShutdown.Both);
}
client.Close();
}
byte[] Data = new byte[REnd];
Array.Copy(MsgBuffer, 0, Data, 0, REnd);
myDataDeal.CmdDataArrival0(Data, ((IPEndPoint)client.RemoteEndPoint).Address);
client.BeginReceive(MsgBuffer, 0, MsgBuffer.Length, 0, new AsyncCallback(ReceiveCallBack0), null);
}
catch (Exception e)
{
pfmMain.writelog("ReceiveCallBack0 error:" + e.Message);
return;
}
}
上面代码运行会出现错误:未从此类上对应的异步方法中返回 IAsyncResult 对象
这个问题困扰我一个星期了。麻烦高手帮忙看下,不胜感激
[ 本帖最后由 lhb62232397 于 2012-3-5 13:32 编辑 ]