-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRON expressions #34
Comments
Hmm, maybe the better way would be to extend the fluent scheduler codebase with a "cron expression parser".
So in essence, you could create Scheduler.FromExpression() which would parse cron expression and return (or fill the properties of the existing class) Scheduler. |
Ok, I'm working on an implementation, but It still needs to be done in the codebase, this because the properties to fill of the Schedule are internal! The class should be the Schedule, no Scheduler class is there... |
I second opening up the CalculateNextRun property. It seems like a great extension point to be able to do all sorts of fancy scheduling stuff. I recently achieved the use of cron expressions by using the NCrontab project (https://code.google.com/p/ncrontab/) whose "GetNextOccurrence" function works perfectly with CalculateNextRun. I just bypassed the internal flag by using reflection. var crontabSchedule = NCrontab.CrontabSchedule.Parse(schedule, new CrontabSchedule.ParseOptions() {IncludingSeconds = true});
s.GetType()
.GetProperty("CalculateNextRun", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(s, (Func<DateTime, DateTime>) crontabSchedule.GetNextOccurrence, null); I think this is a great example though of how opening up this property can enable some advanced scenarios. |
I'm putting this on "on hold" (for comments and opinions from others), even though is an old issue. I don't know if I like the idea of the consumer hooking up how the calculation is done but supporting cron out of the box might not be a bad idea... |
As far as I can see Schedule.cs (a public class) is using the builder pattern. So IMO you could support "builder-style" extension methods in that class, right? These methods - for example So But I'm not sure if that's practical at all because I'm not that experienced with cron calculation. 😄 |
Hi @tallesl. |
With internal It will help to make this property public. |
Any updates on this feature? It is idle for 4 years now. |
See #214. |
Hi,
I've chosen your implementation of a task scheduler because I like the codebase and the fact that the code is using the TPL.
I need to extend the library to support the ability to schedule based on cron espressions. I saw that the Schedule CalculateNextRun Func is internal, so It's impossible for me to implement such a thing.
Now I have to import all your codebase in my project, modified for my needs, but this is not what I really want, so it's possible to have a version which enables extensions?
Thanks
The text was updated successfully, but these errors were encountered: