I have looked at the Task and Timer class API's, but could not find information on how to schedule a Task
for future execution.
Using the Timer
class, I can schedule threads for future execution, but I need to schedule Task
s.
Task
has .Delay(...)
methods, but not sure delay is similar to scheduling.
Edit(clarification): I want to start tasks after x minutes.
You can use the at command to schedule future tasks in a Linux system. Similar to the crontab file that works with the cron daemon, the at command works in conjunction with the atd daemon.
In computing, scheduling is the action of assigning resources to perform tasks. The resources may be processors, network links or expansion cards. The tasks may be threads, processes or data flows. The scheduling activity is carried out by a process called scheduler.
Go to the Scheduled Tasks applet in Control Panel, right-click the task you want to start immediately, and select Run from the displayed context menu.
To schedule is to set up a specific time when something will occur. An example of schedule is when you make a doctor's appointment. Schedule is a plan for when things will occur or events will take place. An example of schedule is the times when your courses start and end.
You should use Task.Delay
(which internally is implemented using a System.Threading.Timer
):
async Task Foo()
{
await Task.Delay(TimeSpan.FromMinutes(30));
// Do something
}
While the delay is "executed" there is no thread being used. When the wait ends the work after it would be scheduled for execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With