문제

전자 책을 만들 수있는 응용 프로그램이 있습니다. 이 응용 프로그램에는 에어 파일을 생성하는 내보내기 모듈이 있지만 시간이 걸릴 수 있습니다 (일부 책은 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 분 동안 Arround가 계속 충돌합니다. 그래서 시간 관련이 있습니다 ... 우리가 3 분이 충돌하는 것에 접근 할 때마다 누군가가 나를 도울 수 있기를 바랍니다.

도움이 되었습니까?

해결책

나는 바울이 예외의 원인에 대해 옳다고 생각합니다. IIS와 ASP.NET에는 요청이 취할 수있는 최대 시간을 제한하는 설정이 있습니다. asp.net의 경우 machine.config 파일에 있습니다 (httpruntime 요소, executionTimeout 속성을 찾으십시오). 내 개발 기계에서 90 초로 설정되었습니다.

그러나 응용 프로그램이 잘못된 요청에 매달리지 않도록하기 위해 해당 설정을 변경하라고 조언하지 않습니다.

오랜 작업은 비동기 실행을 사용해야합니다. 비동기 실행을 통해 실제 작업은 별도의 스레드에서 처리됩니다. 이는 응용 프로그램의 전반적인 성능에 적합한 다른 요청을 처리하도록 요청을 처리하는 스레드를 해방합니다.

이에 대한 좋은 기사가 있습니다. 예를 들어 : http://msdn.microsoft.com/en-us/magazine/cc163725.aspx

다른 팁

종종이 오류는 실제로 제외 예외에서 발생합니다. innerexception을 사용할 수 있습니까?

IIS에는 'Run-Away'스레드 보호 기능이있어 너무 오래 실행되면 스레드/AppDomain을 죽일 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top