コード例 #1
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            //接到连接请求

            //不让客户端缓存
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            //获取唯一标识
            var sessionId = context.Request.QueryString["sessionId"];

            if (Queue.Count(fun => fun.SessionId == sessionId) > 0)
            {
                var index = Queue.IndexOf(Queue.Find(fun => fun.SessionId == sessionId));
                Queue[index].Context = context;
                Queue[index].CallBack = cb;
                return Queue[index];
            }

            //如果不存在则加入队列
            var asyncResult = new MyAsyncResult(context, cb, sessionId);
            Queue.Add(asyncResult);
            return asyncResult;
        }
コード例 #2
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            //接到连接请求

            //不让客户端缓存
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            //获取唯一标识
            var sessionId = context.Request.QueryString["sessionId"];

            if (Queue.Count(fun => fun.SessionId == sessionId) > 0)
            {
                var index = Queue.IndexOf(Queue.Find(fun => fun.SessionId == sessionId));
                Queue[index].Context  = context;
                Queue[index].CallBack = cb;
                return(Queue[index]);
            }

            //如果不存在则加入队列
            var asyncResult = new MyAsyncResult(context, cb, sessionId);

            Queue.Add(asyncResult);
            return(asyncResult);
        }