Thus the files could be recieved anytime during the day, but despite that the task should be schduled to run exactly at 9:00 p.m. in the night.
So I used the following code to schedule a task(using System.Threading.Timer and TimeSpan classes)
DateTime d = DateTime.Now;
timer = new Timer(new TimerCallback(Update), null,
TimeSpan.FromMinutes(21 * 60 - (d.Hour * 60 + d.Minute)),
TimeSpan.FromMilliseconds(-1));
Note I used TimeSpan.FromMillisecnods(-1) to disable periodic signalling
1 comment:
Scheduler Control for C#.NET
Post a Comment