【发布时间】:2013-02-19 13:22:48
【问题描述】:
我正在使用 IHttpAsyncHandler 和 XMLHTTPRequest 在以下 URL 的帮助下将消息推送到客户端:http://www.codeproject.com/Articles/42734/Using-IHttpAsyncHandler-and-XMLHttpRequest-to-push 但我做了一些更改,实际上这个示例仅基于一个客户端,我必须向多个客户端发送消息,所以我进行了这些更改
public void ProcessRequest(HttpContext context)
{
var recipient = context.Request["recipient"];
lock (_obj)
{
string[] totalfrnds = ("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").Split(',');//<- This is just an example for many clients
foreach (var a in totalfrnds)
{
var handle = MyAsyncHandler.Queue.Find(q => q.SessionId == a);//<- check who's client is online or not
if (handle != null)
{
handle.Message = context.Request["message"];
handle.SetCompleted(true);
}
}
}
}
现在我有两个问题
如何解决此类错误?这不是永久性错误,它是随机发生的。
-
W3wp.exe 中异步线程的限制是什么,超过 25 个请求时无法打开下一个请求,我必须重置 IIS 才能重新启动应用程序。
李>
【问题讨论】:
标签: c# multithreading asynchronous push-notification ihttpasynchandler