Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Win32.TaskScheduler RandomDelay

I have written a little program that creates a scheduled task. I wanted this task to run every day at any time between 6pm and 11.59pm. For this reason, I created this trigger

td.Triggers.Add(new DailyTrigger
                {
                    DaysInterval = 1,
                    StartBoundary = DateTime.Today + TimeSpan.FromHours(18),
                    RandomDelay = TimeSpan.FromMinutes(359)
                });

Problem is that in the Task Scheduler window the task that I create always is set to run at 6

enter image description here

What am I doing wrong?

like image 526
Sachin Kainth Avatar asked May 07 '26 01:05

Sachin Kainth


1 Answers

This is the correct syntax to achieve your results. Unfortunately, the Task Scheduler app in Windows does not display information about delays. (BTW, I'm the author of that library and am 100% confident that your task will execute as you desire.) For detail on the functionality of the RandomDelay property see the Microsoft documentation.

like image 198
dahall Avatar answered May 08 '26 16:05

dahall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!