1

On my IIS 7.5, I have an AppPool with startMode="AlwaysRunning". Also, I have AppPool recycling set to 3 minutes for testing.

When I run a long-running task(10 minutes) it throws ThreadAbort. I thought that "AlwaysRunning" will fix it. Why does this happen? Do I have to change anything else?

Divi
  • 7,621
  • 13
  • 47
  • 63
user194076
  • 8,787
  • 23
  • 94
  • 154

1 Answers1

0

The Application Pool recycling is causing the ThreadAbortException because it's closing the pool. Regardless of anything the pool process will be terminated and restarted. Code within the pool cannot prevent this (ThreadAbortException is special in that it can be caught but not consumed).

The startMode="AlwaysRunning" just means that the pool will always be available. It makes no claims about which pool process that is (so after a pool process is terminated it will automatically fire up another one; or that if IIS is restarted it will automatically fire-up w3wp.exe).

Remove the 3-minute recycling cycle time length. I don't see how it benefits testing anyway (as whenever an ASP.NET application is modified IIS will restart the AppDomain).

Dai
  • 141,631
  • 28
  • 261
  • 374
  • Then, how do I occasionally recycle app pool, when no processes are running? or can I control recycling programmatically? This answer tells that this setting will help with keeping alive. http://stackoverflow.com/questions/11140597/iis-app-pool-recycle-quartz-scheduling I have the same setup. I still need to recycle occasionally without interfering with schedule – user194076 Sep 25 '12 at 06:03
  • I'd use IIS Manager to restart the pool, or use Task Manager and kill w3wp.exe directly. – Dai Sep 25 '12 at 06:07
  • No, I mean I need to do it automatically every day like in all other apps, so I avoid memory leakage. I know, I need to fix memory issues, but at this point I just need my scheduler to work through app pool recycling. – user194076 Sep 25 '12 at 06:09
  • You'd have to use an external service that keeps your ASP.NET application alive by periodifically sending GET requests to ensure `Application_Start` is called. I suggest you use a combination of Windows Scheduled Tasks and `wget`. – Dai Sep 25 '12 at 06:18