using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using UAS_PLCDataReader.Entity; namespace UAS_PLCDataReader.PublicMethod { class PollingTask { /// /// 内部调用的任务,添加了取消标识符号 /// Dictionary InTask = new Dictionary(); /// /// 获取任务 /// /// /// public Task GetTask(int TID) { return null; } /// /// 添加任务,默认添加后自动执行,返回创建的TASK的ID /// /// /// //public void AddTask(Action action, string Code) //{ // Task newTask = Task.Factory.StartNew(() => action); // InTask.Add(Code, newTask); //} /// /// 添加任务,默认添加后自动执行,返回创建的TASK的ID /// /// /// public void AddTask(Action action, Polling obj) { Task.Factory.StartNew(action, obj); } /// 添加一系列任务 /// /// public void AddTask(Action[] action) { } /// /// 添加任务 /// /// /// public int AddTask(Action action, bool AutoStart) { return 0; } /// /// 移除任务 /// /// public bool RemoveTask(string Code) { InTask.Remove(Code); return true; } /// /// 移除所有的任务 /// /// public bool RemoveAllTask() { InTask.Clear(); return true; } /// /// 暂停任务 /// /// /// public bool PauseTask(int TID) { return true; } /// /// 开启所有任务 /// public void StartAllTask() { foreach (var item in InTask) { item.Value.Start(); } } ///// ///// 暂停所有任务 ///// //public void PauseAllTask() //{ // //} /// /// 停止所有任务 /// public void StopAllTask() { } /// /// 停止指定任务 /// /// /// public bool StopTask(int TID) { return true; } } }