setting the StartBoundary to a valid DateTime not working

Topics: Errors
Aug 27, 2014 at 11:14 PM
I am using a DateTime value to set the StartBoundary of several Triggers (daily, weekly, monthly).

I am loging the DateTime and StartBoundary after assignment.

The two values are equal.

But when I finally call the RootFolder.RegisterTaskDefinition method and check the Windows System Task Scheduler, I get correct trigger Days, however incorrect Start Time
using (TaskService ts = new TaskService())

    TaskDefinition taskDef = ts.NewTask();

    taskDef.RegistrationInfo.Description = "Any Description";

    DailyTrigger dt = new DailyTrigger();

    dt.StartBoundary = scheduleTime; //(DateTime Value


    taskDef.Actions.Add(new ExecAction(
                "my.exe", "ags", null));

    ts.RootFolder.RegisterTaskDefinition(@"MyTask", taskDef);
Aug 28, 2014 at 4:49 PM
Problem Solved.

After some testing outside of the main project I found that there is a seven (7) hour difference in each time.

To fix this I just check the time difference and update the time just before registering the task.
Marked as answer by noahjanderson on 8/28/2014 at 9:49 AM
Aug 28, 2014 at 9:33 PM
The DateTime structure that is passed to the StartBoundary property will be interpreted as the local time on the system running the tasks unless the DateTime value is constructed with a DateTimeKind value for Utc. A best practice to be very explicit about the DateTime value so that cross-system portability works consistently.
Marked as answer by dahall on 8/28/2014 at 2:33 PM