Reputation: 81
i am using following code for scheduling task in c#
TaskDefinition td = ts.NewTask();
DateTime t = ts.RootFolder.Tasks["Test"].LastRunTime;
td.RegistrationInfo.Description = "Does something";
td.Triggers.Add(new TimeTrigger(DateTime.Now + TimeSpan.FromSeconds(10)));
//td.StartBoundary = DateTime.Today + TimeSpan.FromHours(23);
td.Triggers.Add(new WeeklyTrigger
{
StartBoundary = DateTime.Today + TimeSpan.FromHours(2),
DaysOfWeek = DaysOfTheWeek.Friday
});
i want to add week days more than one...
I found that i can do this by using
DaysOfWeek = DaysOfTheWeek.Monday | DaysOfTheWeek.Tuesday | DaysOfTheWeek.Wednesday
| DaysOfTheWeek.Thursday | DaysOfTheWeek.Friday | DaysOfTheWeek.Saturday
But the problem is that i want to do this dynamically. User will choose on week days and then i will set... pls help how to do this.
Upvotes: 0
Views: 856
Reputation: 5761
You can keep a list of integer with user selections
Then you could do
foreach (int day in days)
{
td.DaysOfWeek |= (DaysOfTheWeek)day;
}
Upvotes: 2