There is not just one thread, web apps are multi threaded. I only meant running a long task in a web request blocks the current thread that i serving the current web request, there is a pool of threads available to a web app, but a single bad performing thread can still bring an app to its knees.
Without knowing more about what your code is actually doing I cannot offer suggestions other than look at the processor and memory utilization on the web server and database server while it runs, consider whether it is locking or blocking any resources or opening lots of db connections etc