简体   繁体   中英

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

在此处输入图片说明

What am I doing wrong?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM