title: A second operation cannot be started when using ContinueWith
body: <p>I have a loop and within the loop I'm doing:</p>
  <pre><code>await Task.Delay(1000, ct).ContinueWith(async _ =&gt;
  {
      await SecondMethodAsync(ct);
  });
  </code></pre>
  <p>The second method gets an entity using EF, sets some properties and saves the entity back to the datastore by calling <code>await SaveChangesAsync()</code> on the <code>DbContext</code>.</p>
  <p>The above should wait for 1s and then continue with the second method. With the above implementation I get the following exception:</p>
  <blockquote>
  <p>A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe.</p>
  </blockquote>
  <p>When I change the above to:</p>
  <pre><code>await Task.Delay(1000, ct);
  await SecondMethodAsync(ct);
  </code></pre>
  <p>Everything works fine.</p>
  <p>What is the difference with the above 2 snippets and how do I get to make the first snippet work?</p>