title: Why does an asp.net user session ending cause a Quartz task in a different app pool to terminate?
body: <p>I'm using C# with the Quartz scheduler within an asp.net application. After a user clicks a button on the front end a Quartz task immediately runs in the background, however the task prematurely terminates when the user session ends.</p>
  
  <p>The user session is a different app pool to the one the Quartz session is running in.</p>
  
  <p>Obviously the desired behaviour is for the task to continue even when the user who initiated the task signs out, or their session ends.</p>
  
  <p>Update:
  I've added more logging information - what actually appears to cause the task to stop is this:</p>
  
  <p>at System.Web.Hosting.HostingEnvironment.StopRegisteredObjects(Boolean immediate)
  at System.Web.Hosting.HostingEnvironment.InitiateShutdownWorkItemCallback(Object state)
  at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
  at System.Threading.ThreadPoolWorkQueue.Dispatch()</p>
  
  <p>The task scheduler class that runs the Quartz tasks was registered in System.Web.Hosting.HostingEnvironment - and when the thread is dispatched it looks like it stops the task scheduler. So this might be closer to where I should be looking - I need to understand why the Thread running the task got dispatched.</p>
  
  <hr>
  
  <p>Initially I thought the problem was do with the Autofac Lifetime scope of the component and my question originally focused on that. I'll leave my Autofac remarks below because it may turn out that this was a factor, I just don't know yet until I solve the problem.</p>
  
  <p>Original Description of Problem:
  I'm investigating an issue where the lifetime scope of a  component is incorrectly behaving as if it is a Request Lifetime scope.</p>
  
  <p>Because there are a lot of dependencies I thought if I inspected the Autofac internal code in the debugger it would help me identify what was causing the problem.</p>
  
  <p>However, I'm finding it difficult to understand how lifetime scope is represented internally in Autofac. </p>
  
  <p>Does anyone know how to find the lifetime scope associated with a component within Autofac - in particular if it has request lifetime scope?</p>