using System; using System.Collections.Generic; using System.Text; namespace APT.Infrastructure.Core { public class APTThreadWork { public APTThreadWork() : this(DateTime.Now) { } public APTThreadWork(DateTime runTime) : this(runTime, null, null, null) { } public APTThreadWork(DateTime runTime, APTThreadTimeRule rule) : this(runTime, rule, null, null) { } public APTThreadWork(DateTime runTime, APTThreadTimeRule rule, object executeObj, Action executeAction) { _runTime = runTime; _executeAction = executeAction; _executeObj = executeObj; _rule = rule; } private DateTime _runTime = DateTime.MinValue; private Action _executeAction = null; private object _executeObj = null; private APTThreadTimeRule _rule = null; internal DateTime RunTime { get { return _runTime; } set { _runTime = value; } } private ThreadState _threadState = ThreadState.Wait; public ThreadState ThreadState { get { return _threadState; } internal set { _threadState = value; } } public virtual bool NextRunTime(ref DateTime runTime) { if (_rule != null) return _rule.NextRuleTime(ref runTime); return false; } public virtual void Execute() { if (_executeAction != null) _executeAction(_executeObj); } } }