0

I'm using c#, winform, I need 3 timers, one that starts every 5 minute at a specific time 09:05, 09:10, 09:15 etc, the second every 1 hour at 10:00, 11:00 etc, and the last one every 4 hours at 13:00, 17:00. All the 3 timer have to start to work at 9 am, it means if I start the program before 9 am, they don't have to do anything, but if I start the program at for example 10, they have to start immediately.

The following is code I use,

    #region Timer
    //5 minute
    int cont=0;
    private void timer5Minuti_Tick(object sender, EventArgs e)
    {
        if (cont_timer == 0) { }
        else
        {
            timer5Minuti.Interval = 300000;

           // myfunction();
        }
    }

    //1 hour
    private void timerH1_Tick(object sender, EventArgs e)
    {
        if (cont_timer == 0) { }
        else
        {
            timerH1.Interval = 3600000;

           // // myfunction();
        }
    }

    //timer che si aggiorna ogni 4 ore
    private void timerH4_Tick(object sender, EventArgs e)
    {
        if (cont_timer == 0) { }
        else
        {
            timerH4.Interval = 14400000;

            // myfunction();
        }
    }
    #endregion
Kalana Demel
  • 3,220
  • 3
  • 21
  • 34
  • You can use quartzjob. It is very useful for this cases. http://www.quartz-scheduler.org/ – OnurBulbul Sep 21 '17 at 08:02
  • See marked duplicate for examples of how to implement code that runs on fixed time multiples (e.g. on multiples of 5 minutes past the hour, etc.) – Peter Duniho Sep 21 '17 at 08:06

0 Answers0