Call dll thru windows service on timely manner?
<p>Below code call my dll as i expected but am not sure how efficient am doing this,bcoz this is my first windows service ever.</p>

<p>i suppose to run this service every 10 mins interval but one thing am not sure,if the previous run took more than 10 min,what's gonna happen?</p>

<p>if you guys find anything wrong or suggest best way to handle is much appreciated</p>

<p>Thanks in Advance</p>

<pre><code>public partial class Service1 : ServiceBase
{
    private Timer _timer;
    private DateTime _lastRun = DateTime.Now;

    public Service1()
    {
        InitializeComponent();
    }

    protected override void OnStart(string[] args)
    {
        log4net.Config.XmlConfigurator.Configure();

        _timer = new Timer(10 * 60 * 1000); // every 10 minutes
        _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
        Shell Dist= new Shell();
        Dist.Distribute();
    }

    protected override void OnStop()
    {
        this.ExitCode = 0;
        base.OnStop();

    }
    private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
        // ignore the time, just compare the date
        if (_lastRun.Date &lt; DateTime.Now.Date)
        {
            // stop the timer while we are running the cleanup task
            _timer.Stop();
            //
            // do cleanup stuff
            //
            _lastRun = DateTime.Now;
            _timer.Start();
        }

    }
</code></pre>
