title: Invoking a list of functions. How to get their return values and use parameter that could be part of a disposed closure?
body: <p>I want invoke a list of functions. All functions return a bool. Depending on the bool, I want to break the loop invoking each function in the list of functions.</p>
  
  <p>The functions requires a parameter which is an Entity Framework DbContext, instantiated in a "using block". There is a warning "Access to disposed closure"</p>
  
  <pre><code>using (var context = new DbContext())
  {
     var fileDeletionProcedure = new List&lt;Action&gt;
     {
         () =&gt; _proc.deleteUsers(Id, context),
         () =&gt; _proc.deleteAccounts(Id, context),
         () =&gt; _proc.deleteMoney(Id, context)
     }
     foreach (var f in fileDeletionProcedure)
     {
         var exit = f.Invoke();
         if (exit)
         {
             break;
         }
     }
  }
  </code></pre>
  
  <p>I want to do something like the code I provided, but <code>Invoke()</code> returns void, anyone have suggestions? Also, how would I deal with that warning regarding disposed closures?</p>
  
  <p>Thanks in advance.</p>