thread.sleep in asp.net
What @Servy said is correct. In addition to his answer I would like to throw my 2 cents. I bet you are using ASP.NET Sessions and you are sending parallel requests from the same session (for example you are sending multiple AJAX requests). Except that the ASP.NET Session is not thread safe and you cannot have parallel requests from the same session. ASP.NET will simply serialize the calls and execute them sequentially.
That's why you are observing this blocking. It will block only requests from the same ASP.NET Session. If you send an HTTP requests from a different session it won't block. This behavior is by design and you can read more about it here
.
ASP.NET Sessions are like a cancer and I recommend you disabling them as soon as you find out that they are being used in a web application:
<sessionState mode="Off" />
No more queuing. Now you've got a scalable application.
I concluded that when I call thread.sleep all the threads even in other requests are being blocked
That conclusion is incorrect. Thread.Sleep
does not block any other thread, it only blocks the current thread. If multiple threads are all being blocked by this line of code then it is because all of those threads are hitting this line of code.