title: How to wait for async timer callbacks
body: <p>I'm using <code>System.Threading.Timer</code> to run some things that are <code>async</code></p>
  
  <p>It means my callbacks are <code>async void</code>.</p>
  
  <pre><code>private async void CallbackAsync(object state) {
      _timer.Change(Timeout.Infinite, Timeout.Infinite);
      await SomethingAsync();
      _timer.Change(TimeToNextCallback, Timeout.Inifinite);
  }
  </code></pre>
  
  <p>With non async callbacks I have used code like this to shut down the timer safely.</p>
  
  <pre><code>using (var waitHandle = new AutoResetEvent(false)) {
      if (_timer.Dispose(waitHandle))        {
          waitHandle.WaitOne();
      }
  }
  </code></pre>
  
  <p>My understanding is that this will not work with async callbacks. The callback will return on the first <code>await</code> and the Timer is unaware of scheduled continations. I.e the code above might return before the continuations has completed (and the callback might try to change a disposed timer).</p>
  
  <p>First, is my understanding correct?</p>
  
  <p>Second, what is the correct way to wait for async callbacks to finish? </p>