title: In asp.net-mvc, how can I run an expensive operation without slowing down user experience?
body: <p>I have an asp.net-mvc website and I am using nhibernate for my ORM.</p>
  
  <p>I have a current controller action that does a basic CRUD update (queries an item from the database and then updates a bunch of values and commits back to the db table). It then returns a simple json response to the client to indicate success or error.</p>
  
  <pre><code> public ActionResult UpdateEntity(MyEntity newEntity)
   {
        var existingEntity = GetFromRepository(newEntity.Id);
        UpdateExistingEntity(newEntity, existingEntity);
        return Json(SuccessMessage);
   }
  </code></pre>
  
  <p>In certain cases (assuming success of commit and if certain fields are changed in my object) I now want to trigger some additional actions (like emailing a bunch of people and running some code that generates a report) but I don't want to slow down the user experience of the person that is doing the update. So my concern is that if I did this:</p>
  
  <pre><code> public ActionResult UpdateEntity(MyEntity newEntity)
   {
        var existingEntity = GetFromRepository(newEntity.Id);
        bool keyFieldsHaveChanged = UpdateExistingEntity(newEntity, existingEntity);
        if (keyFieldsHaveChanged)
       {
            GenerateEmails();
            GenerateReports();
       }
      return Json(SuccessMessage);
   }
  </code></pre>
  
  <p>that it would be too slow for the user experience of someone updating. Is there anyway (asyngc?) to have an expensive operation get triggered off of a controller action but not have that controller action slowed down because of it?</p>