2009-04-30 21 views
2

我們有一個可以創建電子書的應用程序。 此應用程序具有創建AIR文件的導出模塊,但這可能需要一段時間(有些書籍有2500頁)。 如果我們的出口,我們得到以下錯誤:線程正在登錄錯誤

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 

我改變運行executiontimeout 3600秒,但它總是崩潰角落找尋3分鐘。 所以它是時間相關的...每當我們接近3分鐘它崩潰,我希望有人能幫助我。

+0

這是託管的?在共享主機環境?或專用/內部? – meandmycode 2009-04-30 10:14:45

回答

4

我認爲保羅對異常的原因是正確的。 IIS和ASP.NET都具有限制請求可以執行的最大時間的設置。對於ASP.NET,它位於Machine.Config文件中(查找httpRuntime元素,executionTimeout屬性)。它在我的開發機器上設置爲90秒。

但是,我不會建議您更改該設置,因爲它確保您的應用程序不會掛在錯誤的請求上。

長時間運行的任務應該使用異步執行。通過異步執行,實際工作將在單獨的線程上處理。這樣可以釋放處理請求的線程,以處理其他請求,這對您的應用程序的整體性能非常有利。

這裏有一些很好的文章。例如:http://msdn.microsoft.com/en-us/magazine/cc163725.aspx

0

很多時候,這個錯誤實際上是由OutOfMemory異常發生的。 是否有InnerException可用?

0

IIS有一個'失控'線程保護,如果它運行時間太長,它將殺死一個線程/ appdomain。

+0

有辦法控制這些設置,但我實際上並不知道它們是什麼。我剛剛受到這個問題的困擾,並且知道它存在。您將不得不圍繞IIS站點尋找配置何時回收工作進程的幫助。 – 2009-04-30 19:28:06