我们有一个可以创建电子书的应用程序。 此应用程序有一个导出模块,可以创建一个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

我已将运行时执行时间更改为3600秒,但它会在3分钟内崩溃。 所以它是时间相关的......每当我们接近它崩溃的3分钟时,我希望有人可以帮助我。

有帮助吗?

解决方案

我认为保罗对异常的原因是正确的。 IIS和ASP.NET都具有限制请求可以执行的最长时间的设置。对于ASP.NET,它位于Machine.Config文件中(查找httpRuntime元素,executionTimeout属性)。在我的开发机器上设置为90秒。

但我不会建议您更改该设置,因为它确保您的应用程序不会挂在错误的请求上。

长时间运行的任务应该使用异步执行。使用异步执行,实际工作在单独的线程上处理。这将释放处理请求的线程,以处理有助于应用程序整体性能的其他请求。

有一些关于此的好文章。例如: http://msdn.microsoft.com/en-us/magazine /cc163725.aspx

其他提示

通常,此错误实际上是从OutOfMemory异常发生的。 是否有InnerException?

IIS有一个“失控”线程保护,如果线程/ appdomain运行时间太长,它将终止它。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top