Scheduler - samuelgrant/Imperium-Incursions-Waitlist GitHub Wiki

Scheduler

Code tutorial from: https://codinginfinite.com/creating-scheduler-task-seconds-minutes-hours-days/

The Task class allows you to scheduler tasks that will be completed on a regular interval. If you wish to start a task that should run on frequently (such as every few seconds or minutes) set the start time to be one minute after the application starts.

Schedule a task every {X} seconds

// Starts a task at 15 seconds past 3am 
// Repeats it every 30 seconds
Task.IntervalInSeconds(3, 15, 30, () => {
      // Task to do here
});

Schedule a task every {X} minutes

// Starts a task at midnight
// Repeats it every 30 minutes
Task.IntervalInMinutes(0, 00, 30, () => {
      // Task to do here
});

Schedule a task every {X} hours

// Starts a task at 1am
// Repeats it every 2 hours
Task.IntervalInHours(1, 00, 2, () => {
      // Task to do here
});

Schedule a task every {X} days

// Runs a task at 11am every day
Task.IntervalInDays(11, 00, 1, () => {
      // Task to do here
});