title: Is the Action passed to PushStreamContent guaranteed to be called?
body: <p>The WebApi's <a href="https://docs.microsoft.com/en-us/previous-versions/aspnet/hh995250(v%3dvs.118)" rel="nofollow noreferrer"><code>PushStreamContent</code></a> accepts an <code>Action&lt;&gt;</code> or a <code>Func&lt;&gt;</code> that is named "onStreamAvailable" and is supposed to be</p>
  
  <blockquote>
    <p>called when an output stream is available, allowing the action to write to it directly.</p>
  </blockquote>
  
  <p><strong>Is that Action (or Func) guaranteed to be called?</strong></p>
  
  <p>In a situation where the user quickly closes the browser after clicking a link that starts streaming on the server, is it possible that the WebApi framework will not call the lambda at all?</p>
  
  <p><a href="https://meta.stackexchange.com/q/66377/147640">Background</a>: It would be <em>very very convenient</em> to pass a certain handle to the <code>Action</code>, but it absolutely has to <code>Close</code> it. In a situation where the lambda is not called at all, we would end up with a leaked handle.</p>