C # how to implement a loop with a time step

I need to implement a function containing an instruction loop that should run every .01 second, there is a way to implement a loop (for example, for each time step) that can do this in advance thanks

+3
source share
2 answers

You can use the Timer class as follows:

Timer t = new Timer(100);
t.Elapsed += (sender, e) =>
    {
        for (int i = 0; i < 10; i++)
        {
            // your loop
        }
    };

t.Start();
+8
source

You can create a repeating event using the Timer class .

+4
source

Source: https://habr.com/ru/post/1770623/


All Articles