I'm spec'ing out a API for a task scheduler and I would be thankful for your thoughts. This is what I've got so far:
public void Configure(Context ctx) {
// Single tasks
ctx.Run(() => Tasks.First()).Every.Midnight;
ctx.Run(() => Tasks.Second()).Every.Day(8,0));
// Multiple tasks
ctx.Run(() => {
Tasks.Third();
Tasks.Fourth();
}).Every.Day(8,0);
// Triggers:
..Every.Hour(20/*Minute*/);
..Every.Minute(10/*Second*/);
..Every.Second();
}
The run method accepts an Action parameter.
Obviously, I need to support custom triggers to allow users to configure it exactly as they want. It could be done by implementing an interface like:
interface ITask {
bool ShouldRun(DateTime currentDate);
}
.AndReoccur(int numberOfTimes, Timespan interval)
also I'm pretty sure this site is supposed to be for compilable functioning code, maybe this fits on stackoverflow better? \$\endgroup\$