Asynchronous Thread.Sleep Function in a Web Application

I support the ASP.NET web application, which causes the network connection of the user to reset within a few seconds when it executes the procedure. Thus, the page request expires on the user side, since they never receive the response of the web application (the connection dies before it receives the response packet).

To solve this problem, I thought that the ASP.NET page performs an asynchronous function including Thread.Sleep(5000); // sleep for 5 seconds before executing the connection reset. Thus, the browser takes 5 seconds to get a response to the page before their connection is reset.

I have problems using Thread.Sleep and asynchronous functions in ASP.NET. I have never tried to do this before, so I'm not sure about the possible problems that may arise. Does anyone see potential problems starting an asynchronous thread that Thread.Sleepan ASP.NET application contains ? If so, can you think of a better solution?

+5
source share
3 answers

Placing Thread.Sleep in an asynchronous method can contribute to ThreadPool Starvation, since it blocks one of a limited number of threads for several seconds - this thread can disable client requests.

, , ? , .

+3

, , , , System.Threading.Timer Sleep. , ( !).

+1

, -, . , ~ 1-2 , ...

, , a AsyncPage/AsyncHttpHandler.

+1

All Articles