enter image description here

This is the timer schedule: the beginning, the interval, the parameter that it writes to the txt file and the end of the timer. I work on console application in C #. How to make the timer work as shown in the table.

    1 answer 1

    I somehow did not understand what this interval is. The beginning + interval obviously does not converge with the end, but, in general, it does not matter for the algorithm. You need to do the following:

    • Start a dispatcher timer that will work, say, every second.
    • You read your spreadsheet and make a list of timers: when to start, how much to set, and what to do on completion.
    • In the timeout event of the dispatcher’s timer, go over the list and check if it’s time for us to start some kind of timer. If it is time, then we delete the data from the list and create a timer, according to which timeout event, we will write our text to the file.
    • Repeat these steps until our list ends, after which you can complete the program.

    Example of creating a timer:

    //Создаём таймер, который будет срабатывать каждую секунду var timer = new System.Timers.Timer(1000); //Назначаем обработчик, который будет срабатывать по таймауту timer.Elapsed += OnTimeout; //Таймер будет постоянно работать timer.AutoReset = true; timer.Enabled = true; 

    Where the handler might look like this:

     private static void OnTimeout(Object source, ElapsedEventArgs e) { Console.WriteLine("Timer expired"); } 
    • You can write a similar example) - propro17
    • one
      @ propro17, but what is not clear from what I described? What can't you do on your own? - ixSci
    • Show an example of such a timer in C #. And what is time out - propro17
    • @ propro17, updated post - ixSci
    • one
      @ propro17: Why don't you read the documentation? Do you want to write all the code for you? - VladD