title: Why is minimum Threading.Timer interval 15ms despite timeBeginPeriod(1)
body: <p>The following snippet</p>
  
  <pre><code>    [DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")]
      public static extern uint TimeBeginPeriod(uint uMilliseconds);
  
      static void Main(string[] args)
      {
          if (TimeBeginPeriod(1) != 0)
              Console.WriteLine("TimeBeginPeriod failed!");
  
          Console.WriteLine("Sleep");
          Stopwatch sw = Stopwatch.StartNew();
          for (int i = 0; i &lt; 10; i++)
          {
              Thread.Sleep(1);
              Console.WriteLine(sw.ElapsedTicks * 1000d / Stopwatch.Frequency);
              sw.Restart();
          }
  
          Console.WriteLine("Threading.Timer");
          sw = null;
          System.Threading.Timer t = null;
          int n = 0;
  
          t = new Timer(state =&gt;
          {
              if (sw == null)
                  sw = Stopwatch.StartNew();
              else
              {
                  Console.WriteLine(sw.ElapsedTicks * 1000d / Stopwatch.Frequency);
                  n++;
                  sw.Restart();
              }
              if (n == 10)
                  t.Change(Timeout.Infinite, Timeout.Infinite);
          }, null, TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(1));
          Console.ReadKey();
      }
  </code></pre>
  
  <p>will produce e.g. this output:</p>
  
  <pre><code>Sleep
  0.151834939915548
  0.757358826331279
  0.786901687225611
  0.712520725399457
  0.715593741662697
  0.798704863327602
  0.5724889615859
  0.648825479215934
  0.436927039609783
  0.517873081634677
  Threading.Timer
  15.5841035662354
  14.8620145856526
  15.1098812837944
  14.4202684978119
  15.3883384620112
  14.7210748852159
  15.307462261265
  15.7125416777831
  14.5991320125882
  15.6035194417168
  </code></pre>
  
  <p>According to the net, e.g. a <a href="https://stackoverflow.com/a/13521642/709537">comment by Hans Passant</a>, <code>timeBeginPeriod</code> affects the regular (.net) timers. So why does my timer still have this coarse granularity? <code>Thread.Sleep</code> seems to do just fine.</p>
  
  <p>Maybe relevant: This runs on Windows 7, 64bit, .net 4, inside VMWare.</p>