private void InsertJobContext(JobContext context) { if (context.ExecutionTimes == 0) { context.UtcNextExecution = DateTime.UtcNow.AddSeconds(1.0); } else { var interval = context.Job.GetNextInterval(context); if (interval == TimeSpan.MaxValue) return; context.UtcNextExecution = DateTime.UtcNow.Add(interval); } lock (_syncRoot) { var node = _jobs.First; while (node != null) { if ((node.Previous == null || context.UtcNextExecution <= context.UtcNextExecution) && context.UtcNextExecution < node.Value.UtcNextExecution) { _jobs.AddBefore(node, context); break; } node = node.Next; } if (node == null) _jobs.AddLast(context); } }
public JobContext AddJob(IJob job, string jobName = null) { var context = new JobContext(this, job) { Name = jobName }; context.UtcCreation = DateTime.UtcNow; InsertJobContext(context); return context; }
public TimeSpan GetNextInterval(JobContext jobContext) { return TimeSpan.MaxValue; }
public void Execute(JobContext jobContext) { _act(); }
internal void JobExecuted(JobContext context) { InsertJobContext(context); }
internal void JobExecuted(JobContext context) { InsertJobContext(context); }
public void Execute(JobContext jobContext) { _act(); }
public TimeSpan GetNextInterval(JobContext jobContext) { return(TimeSpan.MaxValue); }
public TimeSpan GetNextInterval(JobContext jobContext) { return(TimeSpan.FromSeconds(24 * 3600) - DateTime.Now.TimeOfDay); }
public void Execute(JobContext jobContext) { if (jobContext.ExecutionTimes != 0) Logger.SetLogPath(); }
public TimeSpan GetNextInterval(JobContext jobContext) { return TimeSpan.FromSeconds(24 * 3600) - DateTime.Now.TimeOfDay; }
internal void OnExecuted(object sender, JobContext e) { if (Executed != null) Executed(sender, e); }
internal void OnExecuting(object sender, JobContext e) { if (Executing != null) Executing(sender, e); }