During this I noticed that a “system.Threading.ThreadAbortException: Thread was being aborted.” exception was being thrown approximately after the web part was running for 125 seconds. I found out that the system was throwing this exception and it was because by default .Net threads have an execution time out limit of 110 seconds. To fix this we need to modify the web.config file that Sharepoint uses. The following line needs to be replaced
The executionTimeout value should be set depending on the number of items in the excel sheet. Please refer to the support document below for information on this http://support.microsoft.com/kb/928756.
The other thing to note is when the ThreadAbortException is thrown by the system you cannot catch it in a try catch. If you use a try catch it will go through the catch and at the end of the catch statement it will throw it again.
But if the ThreadAbortException is thrown by our code then we can abort it by using the class Thread.ResetAbort in the finally clause. More info on that can be found on