It is necessary to carry out certain actions on the schedule, an abstract example:
- on Monday at 12:00 take files from the folder
- on Tuesday at 13:39 to create a folder with files
- on the third Friday at 7:03 count the number of files
Is it advisable for this to use the timer with Interval per minute and in its Tick check the time and day of the week?
private void timer1_Tick(object sender, EventArgs e) { var currentTime = DateTime.Now.TimeOfDay; var currentDow = DateTime.Now.DayOfWeek; var oneMinute = new TimeSpan(0, 1, 0); if ((currentDow == DayOfWeek.Monday)&&(currentTime-timeMonday<oneMinute)) { MondayOperation(); } if ((currentDow == DayOfWeek.Tuesday)&&(currentTime-timeTuesday<oneMinute)) { TuesdayOperation(); } if ((currentDow == DayOfWeek.Friday)&&(MyDoWInMonth(DateTime.Now).Equals(3))&(currentTime-timeFriday<oneMinute)) { FridayOperation(); } }