Friday, 12 October 2007

.Net Execution Timout - ThreadAbortException

I had to create a custom web part that read a list of items from an excel sheet and upload it into sharepoints custom list. In that excel sheet there was a url field which pointed to pdf documents on the internet, so while uploading contents into the custom list I also had to download the pdf documents and add them to the custom list as attachments.

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

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


Anonymous said...

Hi. thanks so much , but how can disable the timeout?

Jaime said...

Very useful post and so good. Thanks to show me the way, ;)

Anonymous said...

Thanks Venkat ..