/// <summary> /// Add a new AliveTask (it will be a new Thread) /// </summary> /// <param name="yourName">your task name</param> /// <param name="yourInfo">your task info</param> /// <returns></returns> private bool AddAliveTaskInfo(string yourName, AliveTaskInfo yourInfo) { if (aliveTaskList.ContainsKey(yourName)) { SetErrorMes("existed task name"); return(false); } else { aliveTaskList.Add(yourName, yourInfo); return(true); } }
/// <summary> /// Create New AliveTask [it will not start ] /// </summary> /// <param name="yourTaskName">Task Name</param> /// <param name="sqlcmd">mysql sql (只要sql查询有结果即会在每次时间节点到达时触发事件,如果想要以此结果处理业务,可以在处理业务前Pause(StartAliveTask),处理完成后再Resume(StopAliveTask))</param> /// <param name="intervalTime">ms</param> /// <param name="yourAction">delegateGetAliveTaskDataTableInfoEventHandler</param> /// <returns>is sucess</returns> public bool CreateNewAliveTask(string yourTaskName, String sqlcmd, int intervalTime, delegateGetAliveTaskDataTableInfoEventHandler yourAction) { AliveTaskInfo tempTaskInfo = new AliveTaskInfo(yourTaskName, sqlcmd, intervalTime, this); tempTaskInfo.OnGetAliveTaskDataTableInfo += yourAction; if (AddAliveTaskInfo(yourTaskName, tempTaskInfo)) { tempTaskInfo.CreateAliveTaskThread(); return(true); } else { tempTaskInfo.Dispose(); tempTaskInfo = null; return(false); } }