.net - Handling task schedules -
i'm looking more of discussion of conceptual ideas here, rather specifics (though specifics welcome well). frequent requirement in application environment need able run specific tasks on set schedule (every monday @ 3:00 pm, every weekday @ 6:30 pm, once @ 2:00 pm today, etc).
now, in environment, have built windows service runs on application server handle these events. uses timer expires once per hour , checks if needs done. of these events using hard coded checks of date/time/weekday etc perform tasks. now, obviously, timer runs once per hour, resolution of when event runs time when scheduled 1 hour later. current tasks, fine.
what able handle tasks scheduled arbitrarily, , better resolution on time. now, improved resolution matter of having timer expires every minute check if task needs run. however, first requirement, being able schedule these things arbitrarily, bit more complicated.
the application connected sql database, , front end in web based asp.net application, user interface portion shouldn't issue. wondering following:
i to, @ minimum, able handle schedules of complexity applications sql server agent allow, is, allow recurring item start date , end date (or no end date), frequency (daily, weekly, monthly), specific weekdays selectable weekly scheduling, etc. now, clearly, have field each of these elements in database table, along "last run time" , "next run time" column, seems grossly inefficient me.
so specific questions are: there best practices database data model design storing scheduled tasks?
are there existing .net libraries use storing these schedules on front end, , determining if time run particular job on end? can brute force this, seems common enough requirement, there should out there lot of heavy lifting without having "recreate wheel".
are there pitfalls handling type of requirement have encountered might not obvious?
just use sql agent??? or use windows scheduled task... consider hangfire
what benefit gain writing own?
this harder problem seems existing solutions should leveraged. current idea of polling every minute inefficient , there many subtle bugs when dealing timing this. write jobs in console app instead of service , call existing scheduler. can make front-end create job using sql agent / scheduled task / hangfire interface if want keep custom front-end.
windows services better suited things running all time, not on schedule.
Comments
Post a Comment