This project has moved and is read-only. For the latest updates, please go here.

weekly trigger with mutiple days

Aug 8, 2012 at 12:35 AM
Edited Aug 8, 2012 at 12:36 AM

Does anyone know if there's a way to create a weekly trigger with multiple days? I have only been able to schedule with a weekly trigger on one specific day, or alternatievly on all days. So, for example, I can say:

 td.Triggers.Add(new WeeklyTrigger { StartBoundary = DateTime.Today + TimeSpan.FromHours(2), DaysOfWeek = DaysOfTheWeek.Friday });

It's also possible to specify DayOfWeek = DaysOfTheWeek.AllDays

But what about specifying more than one, but fewer than seven, days on each week (e.g. start the task on Tuesday, Wednesday, and Friday)?

Of course, I could schedule three separate weekly tasks, one to run on Tuesday, one on Wednesday, and one on Friday, but that's a workaround I'll use as a last resort, as it would be cleaner to schedule one weekly task, to run on multiple days, if possible.

Aug 8, 2012 at 12:24 PM
Edited Aug 8, 2012 at 3:52 PM

I figured it out. This can be done using the or concatenator "|" between days so, for example, DaysOfTheWeek.Friday | DaysOfTheWeek.Saturday.

A slight problem I've had, which is probably why I didn't figure this out right away, is that I'm working in VB and most of the examples on here are in C#, so I have been trying to understand the examples based on my rudimentary knowledge of C#, or by using the websites that translate beween VB and C#, but those websites don't always do the translation correctly. For those of you coding in VB, the method to include multiple days with a weekly trigger is to use the word "Or" as the concatenator, so for example, DaysOfTheWeek.Friday Or DaysOfTheWeek.Saturday.

In any case, I've got this resolved. By the way, this scheduler is an excellent piece of software.

Aug 9, 2012 at 12:10 AM

Alas, I have the opposite problem in that I am much more proficient in C# than VB. If you end up with sample code in VB that you would like to share, please pass it along and I'll include it in the documentation.

I'm glad you're finding value in the library. Please take the time to rate it on the download page.

Aug 10, 2012 at 10:46 PM

I did that. Actually, you ought to talk to Microsoft about incorporating it into the .Net framework. I'm surprised that the framework lacks classes natively that do what your libary does.