Domanda

Abbiamo un'applicazione in grado di creare e-book. Questa applicazione ha un modulo di esportazione che crea un file AIR ma ciò può richiedere del tempo (alcuni libri hanno 2500 pagine). Se esportiamo otteniamo il seguente errore:

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

Ho cambiato il mio timeout di esecuzione del runtime a 3600 secondi, ma continua a bloccarsi entro 3 minuti. quindi è legato al tempo ... ogni volta che ci avviciniamo ai 3 minuti in cui si blocca, spero che qualcuno mi possa aiutare.

È stato utile?

Soluzione

Penso che Paul abbia ragione sulla causa dell'eccezione. Sia IIS che ASP.NET hanno impostazioni che limitano il tempo massimo che può richiedere una richiesta. Per ASP.NET si trova nel file Machine.Config (cercare l'elemento httpRuntime, attributo esecuzioneTimeout). È impostato su 90 secondi sulla mia macchina di sviluppo.

Tuttavia, non ti consiglierei di modificare questa impostazione in quanto è lì per assicurarsi che la tua applicazione non si blocchi su una cattiva richiesta.

Le attività a esecuzione prolungata devono utilizzare l'esecuzione asincrona. Con l'esecuzione asincrona, il lavoro effettivo viene gestito su un thread separato. Ciò libera il thread che gestisce la richiesta per gestire altre richieste che è buono per le prestazioni complessive dell'applicazione.

Ci sono alcuni buoni articoli su questo disponibili. Ad esempio: http://msdn.microsoft.com/en-us/magazine /cc163725.aspx

Altri suggerimenti

Molto spesso, questo errore si verifica effettivamente da un'eccezione OutOfMemory. È disponibile una InnerException?

IIS ha una protezione thread 'run-away' che ucciderà un thread / appdomain se viene eseguito troppo a lungo.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top