/// <summary> /// /// </summary> /// <param name="tid"></param> /// <param name="taskbase"></param> static public void AddTimerTask(long tid, TimerTaskModel taskbase) { SzThread tm = GetThreadModel(tid); if (tm != null) { tm.AddTimerTask(taskbase); } }
/// <summary> /// 取消一个任务,键不存在,返回null /// </summary> /// <param name="timerId"></param> public TimerTaskModel RemoveTimerTask(long timerId) { TimerTaskModel timer = null; if (timerTaskQueue.TryGetValue(timerId, out timer)) { timer.Cancel = true; return(timer); } return(null); }
/// <summary> /// 加入任务 /// </summary> /// <param name="timer"></param> public void AddTimerTask(TimerTaskModel timer) { timer.RunAttribute["lastactiontime"] = Utils.TimeUtil.CurrentTimeMillis(); if (timer.IsStartAction) { /*立马执行一次*/ AddTask(timer); } /*添加队列*/ timerTaskQueue.TryAdd(timer.ID, timer); }
/// <summary> /// /// </summary> /// <param name="taskbase"></param> static public void AddGlobTimerTask(TimerTaskModel taskbase) { Init(); backThreadTools.AddTimerTask(taskbase); }
/// <summary> /// 取消一个任务 /// </summary> /// <param name="timer"></param> static public TimerTaskModel RemoveTimerTask(long tid, TimerTaskModel timer) { return(RemoveTimerTask(tid, timer.ID)); }
/// <summary> /// 取消一个任务 /// </summary> /// <param name="t"></param> public TimerTaskModel RemoveTimerTask(TimerTaskModel t) { return(RemoveTimerTask(t.ID)); }