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
As other answers have said, using Thread.Sleep will make a thread sleep... but given that you're writing a web app, I don't think it'll do what you want it to.
If the aim is for users to see things happening one second at a time, you'll need to put the delay on the client side. If you have five one-second delays before you send an HTTP response, that just means the user will have to wait five seconds before they see your result page.
It sounds like you should be doing this with AJAX.
EDIT: As noted in comments, it's probably worth you looking at the window.setTimeout Javascript call. (I don't "do" Javascript, so I'm afraid I won't be able to help with any of the details around that.)