I'm seeing this not wait during specified times.
I've been trying to learn c# and don't know exactly what all the syntax is yet. I just want to know if there are better ways of accomplishing this task.
while (DateTime.Now.DayOfWeek == DayOfWeek.Saturday
&& DateTime.Now.DayOfWeek == DayOfWeek.Sunday
&& DateTime.Now.Hour <=8
&& DateTime.Now.Hour >=18
&& DateTime.Now.Minute <=9)
{
Random waitTime = new Random();
int milliseconds = waitTime.Next(120000, 180000);
System.Threading.Thread.Sleep(milliseconds);
}
I want it to wait while it is saturday, or sunday, if it before 0800, after 1800, or if it is in the first ten minutes of each hour.
The problem is, I've seen it exit the loop at 7:05pm on a monday, which is two conditions. Am I using the && function correctly, or should I replace it with something else?