title: Using Thread.Sleep or Timer in Azure worker role in .NET?
body: <p>I understand that in a Windows service, it is better to use <code>Timer</code> rather than <code>Thread.Sleep(timeout)</code>. However, in all code examples I could find on the Internet that were handling Azure workers, it is <code>Thread.Sleep(timeout)</code> which is used instead of <code>Timer</code>.</p>
  
  <p>Even the default code provided in the Worker project template in Visual Studio uses a <code>Thread.Sleep</code>:</p>
  
  <pre><code>public class WorkerRole : RoleEntryPoint
  {
      public override void Run()
      {
          // This is a sample worker implementation. Replace with your logic.
          Trace.WriteLine("$projectname$ entry point called", "Information");
  
          while (true)
          {
              Thread.Sleep(10000);
              Trace.WriteLine("Working", "Information");
          }
      }
  // ...
  }
  </code></pre>
  
  <p>So far, I've been also using <code>Thread.Sleep</code> in my workers but without really understanding why. So my question is, why using <code>Thread.Sleep(timeout)</code> in Azure worker role rather than <code>Timer</code>? What is the difference between Windows service and Azure worker that leads to this difference in how we are supposed to conceive this kind of application? Is it good or bad to use <code>Timer</code> in Azure workers?</p>
  
  <p>Any explanation with links to some resources explaining the fundamentals of this is welcome as I couldn't find anything so far.</p>