title: Reactive extension fixed Interval between async calls when call is longer than Interval length
body: <p>Here is my <code>Interval</code> definition:</p>
  
  <pre><code>m_interval = Observable.Interval(TimeSpan.FromSeconds(5), m_schedulerProvider.EventLoop)
                  .ObserveOn(m_schedulerProvider.EventLoop)
                  .Select(l =&gt; Observable.FromAsync(DoWork))
                  .Concat()
                  .Subscribe();
  </code></pre>
  
  <p>In the code above, I feed the <code>IScheduler</code> in both <code>Interval</code> &amp; <code>ObserveOn</code> from a <code>SchedulerProvider</code> so that I can unit test faster (<a href="https://msdn.microsoft.com/en-us/library/hh212023(v=vs.103).aspx" rel="nofollow noreferrer">TestScheduler.AdvanceBy</a>). Also, <code>DoWork</code> is an <code>async</code> method.</p>
  
  <p>In my particular case, I want the <code>DoWork</code> function to be called every 5 seconds. The issue here is that I want the 5 seconds to be the time between the end of <code>DoWork</code> and the start of the other. So if <code>DoWork</code> takes more than 5 seconds to execute, let's say 10 seconds, the first call would be at 5 seconds and the second call at 15 seconds.</p>
  
  <p>Unfortunately, the following test proves it does not behave like that:</p>
  
  <pre><code>[Fact]
  public void MultiPluginStatusHelperShouldWaitForNextQuery()
  {    
      m_queryHelperMock
          .Setup(x =&gt; x.CustomQueryAsync())
          .Callback(() =&gt; Thread.Sleep(10000))
          .Returns(Task.FromResult(new QueryCompletedEventData()))
          .Verifiable()
      ;
  
      var multiPluginStatusHelper = m_container.GetInstance&lt;IMultiPluginStatusHelper&gt;();
      multiPluginStatusHelper.MillisecondsInterval = 5000;
      m_testSchedulerProvider.EventLoopScheduler.AdvanceBy(TimeSpan.FromMilliseconds(5000).Ticks);
      m_testSchedulerProvider.EventLoopScheduler.AdvanceBy(TimeSpan.FromMilliseconds(5000).Ticks);
  
      m_queryHelperMock.Verify(x =&gt; x.CustomQueryAsync(), Times.Once);
  }
  </code></pre>
  
  <p>The <code>DoWork</code> calls the <code>CustomQueryAsync</code> and the test fails saying that is was called twice. It should only be called once because of the delay forced with <code>.Callback(() =&gt; Thread.Sleep(1000))</code>.</p>
  
  <p>What am I doing wrong here ?</p>
  
  <p>My actual implementation comes from <a href="https://stackoverflow.com/a/30030553/988127">this example</a>.</p>