title: Implementing asyncronous tasks recalled on time intervals
body: <p>I am trying to implement a workflow that involves waiting for a task to complete in ASP.NET (C#).</p>
  
  <p>A "task" is actually some metadata in a DB that is updated when it is finished. A "listener-application" would be an application that keeps interrogating that task to see if it has finished. The reason I did this was to avoid keeping an open connection between 2 WEB APIs for time consuming operations.</p>
  
  <p>My question is which would be the best solution to do this?</p>
  
  <p>My current implementation:</p>
  
  <pre><code>bool isDone = false;
  while (isDone == false)
  {
      await Task.Delay(5000);
  
      //check if task is done
      //if it is done, the flow will exit this "while" code block
  }
  </code></pre>
  
  <p>Previous implementation that I discarded because, as far as I know, blocks the thread unnecessarily:</p>
  
  <pre><code>bool isDone = false;
  while (isDone == false)
  {
      System.Threading.Thread.Sleep(5000);
  
      //check if task is done
      //if it is done, the flow will exit this "while" code block
  }
  </code></pre>
  
  <p>Is my current implementation correct? Does it blocks the current thread? (which I want to avoid)</p>