예제 #1
0
 /// <summary>
 /// Adds a task to the thread
 /// </summary>
 /// <param name="task">The task to be added</param>
 public void AddTask(XTask task)
 {
     if (!this._tasks.ContainsKey(task.Name))
     {
         this._tasks.Add(task.Name, task);
     }
 }
예제 #2
0
        /// <summary>
        /// Initializes the task manager with the property values specified in the configuration file.
        /// </summary>
        public void Initialize()
        {
            this._taskThreads.Clear();

            var taskService = IoC.Resolve<IScheduleTaskService>();
            var scheduleTasks = taskService.GetAllTasks().ToList().OrderBy(x => x.Seconds);

            //group by threads with the same seconds
            foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
            {
                //create a thread
                var taskThread = new TaskThread();
                taskThread.Seconds = scheduleTaskGrouped.Key;
                this._taskThreads.Add(taskThread);
                foreach (var scheduleTask in scheduleTaskGrouped)
                {
                    var task = new XTask(scheduleTask);
                    taskThread.AddTask(task);
                }
            }

            //one thread, one task
            //foreach (var scheduleTask in scheduleTasks)
            //{
            //    var taskThread = new TaskThread(scheduleTask);
            //    this._taskThreads.Add(taskThread);
            //    var task = new Task(scheduleTask);
            //    taskThread.AddTask(task);
            //}
        }
예제 #3
0
        /// <summary>
        /// Initializes the task manager with the property values specified in the configuration file.
        /// </summary>
        public void Initialize()
        {
            this._taskThreads.Clear();

            var taskService   = IoC.Resolve <IScheduleTaskService>();
            var scheduleTasks = taskService.GetAllTasks().ToList().OrderBy(x => x.Seconds);

            //group by threads with the same seconds
            foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
            {
                //create a thread
                var taskThread = new TaskThread();
                taskThread.Seconds = scheduleTaskGrouped.Key;
                this._taskThreads.Add(taskThread);
                foreach (var scheduleTask in scheduleTaskGrouped)
                {
                    var task = new XTask(scheduleTask);
                    taskThread.AddTask(task);
                }
            }


            //one thread, one task
            //foreach (var scheduleTask in scheduleTasks)
            //{
            //    var taskThread = new TaskThread(scheduleTask);
            //    this._taskThreads.Add(taskThread);
            //    var task = new Task(scheduleTask);
            //    taskThread.AddTask(task);
            //}
        }
예제 #4
0
 /// <summary>
 /// Adds a task to the thread
 /// </summary>
 /// <param name="task">The task to be added</param>
 public void AddTask(XTask task)
 {
     if (!this._tasks.ContainsKey(task.Name))
     {
         this._tasks.Add(task.Name, task);
     }
 }