logic required in onstart method in c#.net
<p>On using window service of c# I want to run the service based on my configuration tags, actually I will set the three tags of values in app.config as here below mentioned</p>

<pre><code>&lt;add key ="FIREHOST_TIME" value ="5" &gt;&lt;/add&gt;
&lt;add key ="SETDAYS" value ="3" &gt;&lt;/add&gt;
&lt;add key ="RUN_NOW" value ="1" &gt;&lt;/add&gt; &lt;!-- 0=no, 1=yes--&gt;
</code></pre>

<p>If suppose RUN_NOW value is 1,</p>

<p>when service starts it has to do work now and for next instance it should to run based by SETDAYS tags.</p>

<p>if suppose RUN_NOW value is 0,</p>

<p>when service starts it should not do the work it should wait for SETDAYS to come,then next instance should to run for every set days tag.</p>

<p>Here below I have pasted by code:</p>

<pre><code>   protected override void OnStart(string[] args)
    {
     DateTime tenAM = DateTime.Today.AddHours(FIREHOST_TIME);



            if (DateTime.Now &gt; tenAM)
                tenAM = tenAM.AddDays(SETDAYS);


            // calculate milliseconds until the next 10:00 AM.  
            int timeToFirstExecution = (int)tenAM.Subtract(DateTime.Now).TotalMilliseconds;

            // calculate the number of milliseconds in 24 hours.   
            int timeBetweenCalls = (int)new TimeSpan(24, 0, 0).TotalMilliseconds;

            TimerCallback methodToExecute = kickstart;

            // start the timer.  The timer will execute "ProcessFile" when the number of seconds between now and   
            // the next 10:00 AM elapse.  After that, it will execute every 24 hours.   
            System.Threading.Timer timer = new System.Threading.Timer(methodToExecute, null, timeToFirstExecution, timeBetweenCalls);


         }
</code></pre>

<p>So now I have to use tag help RUN_NOW and implement the logic, kindly advice how to perform.</p>
