[Solved] Increment variable by X every second [closed]


Do you want to make it single-threaded?

int i = 0;
while (i < max)
{
    i++;
    Thread.Sleep(x); // in milliseconds
}

or multi-threaded:

static int i = 0; // class scope

var timer = new Timer { Interval = x }; // in milliseconds
timer.Elapsed += (s,e) =>
    {
        if (++i > max)
            timer.Stop();
    };
timer.Start();

8

solved Increment variable by X every second [closed]