控件在载入时产生一个SOCKET对象,客户端连接这个SOCKET,服务器根据收到的数据产生一个事件(异步接受数据),
但在使用这个事件时,却有错误
test.cancle+=new test.CancleEventHanlder(test_cancle);
try
{
this.Page.Response.Redirect("http://www.163.com",true);
}
catch(Exception ee)
{string xx = ee.Message;
//xx = “响应在此上下文中不可用”;//接受到事件后产生事件
void OnDataReceived(IAsyncResult asyn)
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState;
try
{
int iRx = socketData.m_currentSocket.EndReceive (asyn);
string receive = System.Text.Encoding.ASCII.GetString(socketData.dataBuffer,0,iRx);
if(receive.Length > 0)
{
OnCancle(null);
}
}
}
但在使用这个事件时,却有错误
test.cancle+=new test.CancleEventHanlder(test_cancle);
try
{
this.Page.Response.Redirect("http://www.163.com",true);
}
catch(Exception ee)
{string xx = ee.Message;
//xx = “响应在此上下文中不可用”;//接受到事件后产生事件
void OnDataReceived(IAsyncResult asyn)
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState;
try
{
int iRx = socketData.m_currentSocket.EndReceive (asyn);
string receive = System.Text.Encoding.ASCII.GetString(socketData.dataBuffer,0,iRx);
if(receive.Length > 0)
{
OnCancle(null);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货