C#如何实现与时间步循环 [英] C# how to implement a loop with time step

查看:324
本文介绍了C#如何实现与时间步循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现一个函数,它包含一个循环的指令,应该运行每一个.01秒是有一种方法来实现循环(例如对于每个时间步骤),可以做到
提前感谢


I need to implement a function that 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

推荐答案

你可以这样使用Timer类:

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();

这篇关于C#如何实现与时间步循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆