Is it sane to use Thread.Sleep(int) in ASP.NET or should I use another method?

jcolebrand picture jcolebrand · Mar 16, 2011 · Viewed 11k times · Source

I want to introduce a slight wait during some testing functions, to simulate a server call. Is it sane to use Thread.Sleep(int) to introduce the wait or is there a better method to have the server wait?

Note, I'll be pausing long enough for me to visually see a sufficient lag, even tho I don't expect to see such a delay in the actual app. This is for me to visualize the actual delay that could occur.

I plan on running this both in the VS2010 local debugger webserver and in IIS 7. I'm on .NET 3.5

Answer

The Muffin Man picture The Muffin Man · Mar 16, 2011

Thread.Sleep(int) is what I would use.