Windows Service that runs every week strictly by monday 4am
<p>I have this Service that MUST run on a weekly basis every Monday 4am. Searching through Google I came up with this code:</p>

<pre><code>Timer ServiceTimer;
DateTime scheduleTime;

private void ScheduleRun()
{
    int daySet = (Convert.ToInt16(Settings.Default.DayOfWeekRun) - (int)DateTime.Today.DayOfWeek + 7) % 7;
    scheduleTime = DateTime.Today.AddDays(daySet).AddHours(Convert.ToDouble(Settings.Default.TimeOfDayRun));
    if (daySet == 0 &amp;&amp; scheduleTime &lt; DateTime.Now)
    {
        scheduleTime = DateTime.Today.AddDays(7).AddHours(Convert.ToDouble(Settings.Default.TimeOfDayRun));
    }
}

public Airt_Service()
{
    InitializeComponent();
    ServiceTimer = new System.Timers.Timer();
    ScheduleRun();
}

protected void ServiceTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
    TimeSpan ts = new TimeSpan(7, 0, 0, 0);
    runProcessCode();
}

protected override void OnStart(string[] args)
{
    ServiceTimer.Interval = scheduleTime.Subtract(DateTime.Now).TotalSeconds * 1000;
    ServiceTimer.Elapsed += new System.Timers.ElapsedEventHandler(ServiceTimer_Elapsed);
    ServiceTimer.Start();
}
</code></pre>

<p>What seems to be missing here? I already tried debugging it and seems to work (with 2mins interval). Is there something wrong having an interval of 1week (in milliseconds)?</p>