views:

547

answers:

3

Hi,

We have an application that can create e-books. This application has an export module that creates an AIR file but this can take a while (some books have 2500 pages). If we export we get the following error:

Thread was being aborted. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Threading.ThreadAbortException: Thread was being aborted.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 

[ThreadAbortException: Thread was being aborted.]
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +501
   System.Web.ApplicationStepManager.ResumeSteps(Exception error) +564
   System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +141
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +436

I've changed my runtime executiontimeout to 3600 secs but it keeps crashing arround 3 minutes. so it is time related ... everytime we approach the 3 minutes it crashes, I hope someone can help me out.

A: 

Quite often, this error actually occurs from an OutOfMemory exception. Is there an InnerException available?

Sonny Boy
this could be possible because those e-books are very large ... i'll try it.
Sem Dendoncker
A: 

IIS has a 'run-away' thread protection that will kill a thread/appdomain if it runs for too long.

Paul Alexander
anything i can do about it?
Sem Dendoncker
There are ways to control these settings, but I don't actually konw what they are. I've just been hit by the issue myself and know that it exists. You'll have to dig around the IIS sites for help on configuring when it recycles the worker processes.
Paul Alexander
+2  A: 

I think Paul is right about the cause of the exception. Both IIS and ASP.NET have settings that limit the maximum amount of time a request can take. For ASP.NET it's in the Machine.Config file (look for the httpRuntime element, executionTimeout attribute). It's set to 90 seconds on my development machine.

I would however not advise you to change that setting as it's there to make sure your application doesn't hang on a bad request.

Long running tasks should use asynchronous execution. With async execution, the actual work is handled on a separate thread. This frees the thread that handles the request to handle other requests which is good for the overall performance of your application.

There are some good articles on this available. For example : http://msdn.microsoft.com/en-us/magazine/cc163725.aspx

Marnix van Valen