In my current project there is a need to schedule a method to run at set intervals e.g. once a week, and currently this is done via a windows service creating an HttpClient and
If you need to schedule a background task to run every week, you can use FluentScheduler (NuGet link) to run it for you. You can do something like this:
public class WeeklyRegistry : Registry
{
public WeeklyRegistry()
{
Schedule().ToRunEvery(1).Weeks(); // run WeeklyTask on a weekly basis
}
}
public class WeeklyTask : IJob
{
public void Execute()
{
// call the method to run weekly here
}
}
Update The new version of FluentScheduler changed the API slightly. The task should now be derived from IJob, not ITask. Updated my example to reflect this.