public void EnQueue(LongTask task) {
            this.tasks.Add(task);
            if(task.Queue.noContent())return;
            task.WaitQueue = true;
            try {



                while (getCurrentWeight(task.Queue) > (task.QueueLimit + task.QueueWeight)) {
                    if (task.HaveToTerminate) {
                        task.Terminate();
                        throw new Exception("ожидание очереди прервано");
                    }
                    if (null!=task.Context && null!=task.Context.Response && !task.Context.Response.IsClientConnected) {
                        task.Terminate();
                        throw new Exception("ожидание очереди прервано");
                    }

                    Thread.Sleep(task.QueueWaitRate);
                }
            }
            finally {
                task.WaitQueue = false;
            }
            
        }
Esempio n. 2
0
    	public IAsyncResult BeginRender() {
        	new ReportLogger().start(System.Web.HttpContext.Current);

            render = _render;
            this.task = new LongTask
                            {
                                Comment = Params["tcode"],
                                User = myapp.usrName,
                                Start = DateTime.Now,
                                Type = "report",
                                Context =  System.Web.HttpContext.Current,
                            }
            ;
            
            myapp.Longtasks.Add(task);

            Conversation.Data["current_user"] = myapp.usr;
            Conversation.Data["context"] = System.Web.HttpContext.Current;
        	this.ctx = System.Web.HttpContext.Current;
            return render.BeginInvoke(Conversation, ControllerContext.Async.Callback,
                                      ControllerContext.Async.State);
        }