Example #1
0
        public static void RemoveTask(int scheID)
        {
            BaseTask model = TaskList.FirstOrDefault(p => p.scheMod.ID == scheID);

            if (model != null)
            {
                model.Stop(); TaskList.Remove(model);
            }
        }
Example #2
0
        //------------------------------
        private static BaseTask CreateTask(M_Content_ScheTask model)
        {
            BaseTask task = null;

            switch (model.TaskType)
            {
            case (int)M_Content_ScheTask.TaskTypeEnum.ExecuteSQL:
                task = new T_ExecuteSQL(model);
                break;

            //case (int)M_Content_ScheTask.TaskTypeEnum.Release:
            //    break;
            case (int)M_Content_ScheTask.TaskTypeEnum.Content:
                task = new T_Content_Release(model);
                break;
            }
            return(task);
        }
Example #3
0
 //------------------------------
 /// <summary>
 /// 添加或更新一个任务,如果已存在(TaskID),则会将其加入
 /// </summary>
 public static void AddTask(M_Content_ScheTask scheMod)
 {
     //已完成或禁用任务不进入初始化队例
     if (scheMod.Status != 0)
     {
         return;
     }
     if (scheMod.ID < 1)
     {
         TaskList.Add(TaskCenter.CreateTask(scheMod));
     }
     else
     {
         BaseTask model = TaskList.FirstOrDefault(p => p.scheMod.ID == scheMod.ID);
         if (model != null)
         {
             TaskCenter.RemoveTask(model.scheMod.ID);
         }
         model = TaskCenter.CreateTask(scheMod);
         TaskList.Add(model);
         model.Start();
     }
 }