public void Initialize(ITask[] startPoints) { _nextTaskList = new List<ITask>(startPoints); _parallelsList = new List<Task>(); _startingPorints = startPoints; currentTask = new Task(executeTasks); currentTask.ContinueWith(createNextTask); }
public void Initialize(ITask[] startPoint) { _executionQueue = new ConcurrentQueue<ITask>(); _startPoint = startPoint; _isRunning = false; _shouldStop = false; foreach (ITask task in startPoint) _executionQueue.Enqueue(task); _mainThread = new Thread(Process); }
/// <summary> /// Initializes a new instance of the CompositeTaskFacts class. /// </summary> public CompositeTaskFacts() { this.tasks = new ITask[TaskCount]; for (int i = 0; i < TaskCount; ++i) { var task = new FakeTask(); task.ExecuteFunction = this.TaskCounterFunction; task.VerifyFunction = this.TaskCounterFunction; this.tasks[i] = task; } }
public void Add(List<ITask> tasks) { _tasks = _tasks.ToList().Concat(tasks).ToArray(); }
public void Add(ITask task) { var tasks = _tasks.ToList(); tasks.Add(task); _tasks = tasks.ToArray(); }
public MockTaskGroup(List<ITask> tasks) { _tasks = tasks.ToArray(); }
public MockTaskGroup(params ITask[] tasks) { _tasks = tasks; }
public TaskWithEnumerationsInFields(ITask a, ITask b, SomeTask c) { A = new [] {a}; B = new[] {b}; C = new List<SomeTask> {c}; }
private PrioritySelector(int size) { size = Math.Max(1, size); mConditions = new ICondition[size]; mTasks = new ITask[size]; }
/// <summary> /// 停止服务管理器。 /// </summary> public void Stop() { if (this.started) { lock (this.syncObject) { if (this.started) { this.StopTrace(); try { if (this.configFileChangedEventHandler != null) { XMS.Core.Container.ConfigService.ConfigFileChanged -= this.configFileChangedEventHandler; } // 停止所有宿主 for (int i = 0; i < this.tasks.Length; i++) { try { if (this.tasks[i] is IIntervalTask) { ((IIntervalTask)this.tasks[i]).Stop(); } XMS.Core.Container.LogService.Info(String.Format("成功停止名称为 {0} 的任务", this.tasks[i].Name), LogCategory.Task); } catch (Exception err) { XMS.Core.Container.LogService.Warn(String.Format("在停止任务的过程中发生错误,该任务的名称为 {0}", this.tasks[i].Name), LogCategory.Task, err); } } this.tasks = null; this.started = false; } catch (Exception err2) { XMS.Core.Container.LogService.Warn("在停止任务管理器的过程中发生错误", LogCategory.Task, err2); } } } } }
/// <summary> /// 启动服务管理器。 /// </summary> public void Start() { if (!this.started) { lock (this.syncObject) { if (!this.started) { try { this.tasks = CreateTasks(this.taskTypes, this.taskTypeInstances); // 打开新的宿主 for (int i = 0; i < this.tasks.Length; i++) { try { if (this.tasks[i] is IIntervalTask) { ((IIntervalTask)this.tasks[i]).Start(); XMS.Core.Container.LogService.Info(String.Format("成功启动名称为 {0} 的任务", this.tasks[i].Name), LogCategory.Task); } else { this.tasks[i].Execute(null); } } catch (Exception err) { XMS.Core.Container.LogService.Warn(String.Format("在启动任务的过程中发生错误,该任务的名称为 {0}", this.tasks[i].Name), LogCategory.Task, err); } } if (this.configFileChangedEventHandler == null) { this.configFileChangedEventHandler = new ConfigFileChangedEventHandler(this.configService_ConfigFileChanged); } XMS.Core.Container.ConfigService.ConfigFileChanged += this.configFileChangedEventHandler; this.started = true; } catch (Exception err2) { XMS.Core.Container.LogService.Warn("在启动任务管理器的过程中发生错误", XMS.Core.Logging.LogCategory.Task, err2); } finally { this.StartTrace(); } } } } }