有一个c# 的程序 运行 一个半小时左右时,出现" 无法创建新的堆栈防护页面",
程序很简单,就一个Http的服务器,处理很小的字符串请求,大神请出招......privatevoidBr_kp_DoWork(objectsender,DoWorkEv...
程序很简单,就一个Http的服务器,处理很小的字符串请求,大神请出招......
private void Br_kp_DoWork(object sender, DoWorkEventArgs e)
{
try
{
string locaurl = Fmath.dbCon("locaurl");
string ipport = locaurl == "" ? string.Format("http://{0}:6501/", clientIp) : locaurl;
Brpint(Pint.Runlog, "本机URL:" + ipport);///调用进度
if (Listener.IsListening)
{
Listener.Close();
}
Listener = new HttpListener();
Listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
Listener.Prefixes.Add(ipport);
Listener.Start();
Brpint(Pint.Runlog, "自动开票启动中...");
me_clstart.Enabled = false;
me_clstop.Enabled = true;
while (Listener.IsListening)
{
HttpListenerContext listener = Listener.GetContext();
{
listener.Response.StatusCode = 200;
HttpListenerRequest request = listener.Request;
{
string clientIpPort = request.RemoteEndPoint.ToString();//客户端IP及端口
Stream inputStream = request.InputStream;
byte[] buffer = new byte[256];
int getLength = inputStream.Read(buffer, 0, buffer.Length);
string inmsg = "";///收到的文件消息 内容;
if (getLength != 0) ///将消息写入buffer;
{
inmsg = Encoding.Default.GetString(buffer, 0, getLength);//识别消息
}
using (Stream outputStream = listener.Response.OutputStream)
{
byte[] bf = Encoding.Default.GetBytes("[OK]");
outputStream.Write(bf, 0, bf.Length);
listener.Response.Close();
}//处理返回数据!
if (inmsg.Contains(","))
{
Brpint(Pint.Runlog, "处理:" + inmsg);
KpPrint(inmsg.Split(',')[0]);///开票过程
}///处理数据完成//
}///处理请求完成
}///处理连接完成
}//处理监听完成
}
catch (Exception Err)
{
Brpint(Pint.Runlog, "处理停止..." + Err.Message);
Fmath.RunLog(Err.ToString());
}
} 展开
private void Br_kp_DoWork(object sender, DoWorkEventArgs e)
{
try
{
string locaurl = Fmath.dbCon("locaurl");
string ipport = locaurl == "" ? string.Format("http://{0}:6501/", clientIp) : locaurl;
Brpint(Pint.Runlog, "本机URL:" + ipport);///调用进度
if (Listener.IsListening)
{
Listener.Close();
}
Listener = new HttpListener();
Listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
Listener.Prefixes.Add(ipport);
Listener.Start();
Brpint(Pint.Runlog, "自动开票启动中...");
me_clstart.Enabled = false;
me_clstop.Enabled = true;
while (Listener.IsListening)
{
HttpListenerContext listener = Listener.GetContext();
{
listener.Response.StatusCode = 200;
HttpListenerRequest request = listener.Request;
{
string clientIpPort = request.RemoteEndPoint.ToString();//客户端IP及端口
Stream inputStream = request.InputStream;
byte[] buffer = new byte[256];
int getLength = inputStream.Read(buffer, 0, buffer.Length);
string inmsg = "";///收到的文件消息 内容;
if (getLength != 0) ///将消息写入buffer;
{
inmsg = Encoding.Default.GetString(buffer, 0, getLength);//识别消息
}
using (Stream outputStream = listener.Response.OutputStream)
{
byte[] bf = Encoding.Default.GetBytes("[OK]");
outputStream.Write(bf, 0, bf.Length);
listener.Response.Close();
}//处理返回数据!
if (inmsg.Contains(","))
{
Brpint(Pint.Runlog, "处理:" + inmsg);
KpPrint(inmsg.Split(',')[0]);///开票过程
}///处理数据完成//
}///处理请求完成
}///处理连接完成
}//处理监听完成
}
catch (Exception Err)
{
Brpint(Pint.Runlog, "处理停止..." + Err.Message);
Fmath.RunLog(Err.ToString());
}
} 展开
2017-04-28
展开全部
很有可能就是出现死循环了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询