G
G
Georgy Kuznetsov2021-06-06 13:37:16
C++ / C#
Georgy Kuznetsov, 2021-06-06 13:37:16

What are the ways to perform a certain action every second?

Let's say we have a loop:

while(true) 
{
  ... место для кода ...
}


how to set the command "if a second has passed - do an action" in it?

PS Finding milliseconds from the start of the program and checking whether they leave the remainder of the division by 1000 is not an option, the cycle will most likely "jump" the moment when the number of milliseconds is equal to the remainder of the division by 1000

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Satisfied IT, 2021-06-06
@JoeSmith3100

And who's stopping you from using a regular timer?
https://metanit.com/sharp/tutorial/11.9.php

V
Vladimir Korotenko, 2021-06-06
@firedragon

If (<= condition)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question