dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.2k stars 191 forks source link

Run Task Every Specific Minutes #924

Closed Gorkido closed 2 years ago

Gorkido commented 2 years ago

I want to create a task schedule every specified minutes. How to do that?

dahall commented 2 years ago
TimeTrigger tt = new TimeTrigger();
// Set the time in between each repetition of the task after it starts to 30 minutes.
tt.Repetition.Interval = TimeSpan.FromMinutes(30); // Default is TimeSpan.Zero (or never)
// Set the time the task will repeat to 1 day.
tt.Repetition.Duration = TimeSpan.FromDays(1); // Default is TimeSpan.Zero (or forever)
// Set the task to end even if running when the duration is over
tt.Repetition.StopAtDurationEnd = true; // Default is false;
Gorkido commented 2 years ago
TimeTrigger tt = new TimeTrigger();
// Set the time in between each repetition of the task after it starts to 30 minutes.
tt.Repetition.Interval = TimeSpan.FromMinutes(30); // Default is TimeSpan.Zero (or never)
// Set the time the task will repeat to 1 day.
tt.Repetition.Duration = TimeSpan.FromDays(1); // Default is TimeSpan.Zero (or forever)
// Set the task to end even if running when the duration is over
tt.Repetition.StopAtDurationEnd = true; // Default is false;

Thanks