Ejemplo n.º 1
0
        /// <summary>
        /// On a derived class, this Method can push an SchedulingRequest, so it will be executed immediately
        /// </summary>
        /// <param name="requestId">the unique id of the request that requires immediate execution</param>
        /// <returns>a value indicating whether the request was found and pushing was successful</returns>
        public override bool PushRequest(string requestId)
        {
            bool retVal = false;

            lock (pendingRequests)
            {
                if (pendingRequests.Any(n => n.RequestId == requestId))
                {
                    PeriodScheduleRequest request = pendingRequests.First(n => n.RequestId == requestId);
                    pendingRequests.Remove(request);
                    request.Task.LastExecution = DateTime.Now;
                    base.ScheduleTask(request);
                    retVal = true;
                }
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Schedules a task for execution
        /// </summary>
        /// <param name="task">the task that needs to be executed</param>
        /// <returns>a value indicating whether the task was scheduled</returns>
        public override bool ScheduleTask(TaskScheduler.ScheduleRequest task)
        {
            PeriodScheduleRequest schereq = task as PeriodScheduleRequest;

            if (schereq == null)
            {
                return(false);
            }

            /*if (task.Task.SchedulerInstruction == null)
             * {
             *  return base.ScheduleTask(task);
             * }*/

            DateTime?next = schereq.NextExecution;

            if (next == null)
            {
                return(false);
            }

            if (next.Value > DateTime.Now)
            {
                lock (pendingRequests)
                {
                    pendingRequests.Add(schereq);
                }
            }
            else
            {
                task.Task.LastExecution = DateTime.Now;
                return(base.ScheduleTask(task));
            }

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a Task request for this TaskScheduler with the Task that needs to be executed and the queue that will execute it
        /// </summary>
        /// <param name="parallelTaskProcessor">the TaskProcessor that will run the provided task later</param>
        /// <param name="task">the task that needs to be executed</param>
        /// <param name="instruction">the default instruction for this schedule request</param>
        /// <returns>a scheduler - request for the given processor and task</returns>
        public override ScheduleRequest CreateRequest(ParallelTaskProcessor parallelTaskProcessor, ITask task)
        {
            PeriodScheduleRequest retVal = new PeriodScheduleRequest(UniqueName, parallelTaskProcessor, task, this, task.LastExecution);

            return(retVal);
        }