Task Scheduler by c# ( Use Hangfire + mongodb)

new project
  • Hangfire.Mongo ( for storage data to MongDB )
  • MongoDB.Driver ( for storage data to MongDB )
neget package
startup.cs
backgroundJob.Enqueue(() => Console.WriteLine(“Hello world from Hangfire!”));
RecurringJob.AddOrUpdate("some-id", () => task, recurringparmaeter);
  1. Cron.Daily(int hour, int minute) : run hour and minute from parameter
  2. Cron.hour : run every hour
  3. Cron.Hourly(int minute);
  4. Cron.MinuteInterval(int interval);
  5. Cron.MonthInterval(int interval);
  6. Cron.Weekly(DayOfWeek dayOfWeek, int hour, int minute);
  7. Cron.Yearly();
  8. Cron.Yearly(int month);
  9. Cron.Yearly(int month, int day);
  10. Cron.Yearly(int month, int day, int hour);
  11. Cron.Yearly(int month, int day, int hour, int minute);
app.UseHangfireDashboard();
app.UseHangfireDashboard(“/hangfire”, new DashboardOptions{ Authorization = new[] { new MyAuthorizationFilter() } });
hangfire dashboard
hangfire data in mongo

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store