开发者

C# how to implement a loop with time step

I need to implement a function tha开发者_开发问答t contains a loop of instructions that should run every .01 second is there a way to implement a loop(e.g for each time step) that can do that thanks in advance


You can use Timer class like this:

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

t.Start();


You can generate a recurring event using the Timer class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜