How to add some delay between each iteration of for loop in C#?

前端 未结 6 1641
轻奢々
轻奢々 2020-12-22 11:32

I\'m working on ASP.NET MVC3 with C#. I want to add some delay between each iteration of for loop.

for(int i=0; i<5; i++)
{
    //some code
    //add dela         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 12:03

    You can use something like a one-second delay:

    System.Threading.Thread.Sleep (1000);
    

    though make sure this is only for debugging purposes. There's little more annoying than intentionally slowing down software.

    Other than an easy way to introduce performance improvements later, of course :-)

提交回复
热议问题