title: Thread.sleep vs Task.delay in rest api
body: <p>I was comparing Thread.sleep vs task.delay. to check for a job completion status from db. The job will be performed by some other Azure component .</p>
  
  <p>To test it, Created small api with sync and async pattern.</p>
  
  <p>http rest api using async :</p>
  
  <pre><code>public async Task&lt;HttpResponseMessage&gt; Post()
  {
      await Task.Delay(200);
      return await Task.FromResult(new HttpResponseMessage());}
  </code></pre>
  
  <p>http rest api using sync :</p>
  
  <pre><code>public HttpResponseMessage Post()
  {
      Thread.sleep(200);
      return new HttpResponseMessage();}
  </code></pre>
  
  <p>Interestingly. the results were good for Sync call. Tried with 100 users with 5 iteration using Apache jmeter.</p>
  
  <blockquote>
    <p>Sync result.: min : 414 ms average : 8464 ms</p>
    
    <p>Async result : min 1756 ms average : 10044 ms</p>
  </blockquote>
  
  <p>Why Thread.sleep is better than Async. is this overhead of Task creation? Can't I get better results than these two?</p>