title: Windows service stuck in 'starting' state and difference between Thread.Sleep() and Task.Delay()
body: <p>my windows service was stuck in starting state. Below was the code inside <code>onstart()</code>.<code>log()</code> will log some value to a file. </p>
  
  <pre><code>while (true)
          {
              log();
              Thread.Sleep(TimeSpan.FromMinutes(5));
          }
  </code></pre>
  
  <p>after some experiments i changed <code>onstart()</code> to </p>
  
  <pre><code>while (true)
          {
              log();
              await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false);
          }
  </code></pre>
  
  <p>once i changed the code service state changed to running and works fine.
  What is the difference between Thread.Sleep() and Task.Delay() i thought both are delaying execution. Can anyone help me to understand</p>