1

I have an IObservable that generates a value every second, followed by a select that runs some code that may take some time:

var events = Observable.Interval(TimeSpan.FromSeconds(1));
ssoInfoObservable = events
    .Select(e =>
    {
        // ... perform long-running operation ...
    })

The long-running operation may take more than one second so the first question is: will Rx push a new event even though handling of the previous hasn't finished yet? I suppose it will.

Second question is: how can I skip events while a previous event is still being handled?

Ronald Wildenberg
  • 31,634
  • 14
  • 90
  • 133
  • Please see [Whats a good way to run periodic tasks in c# using Rx with a single concurrent execution restriction?](http://stackoverflow.com/a/31400259/638167) which seems pretty much what you need – Absolom Jul 16 '15 at 16:29
  • Ah, seems this already works as I want it to :) That's nice. Thanks! I should mark this as a duplicate I guess :) – Ronald Wildenberg Jul 16 '15 at 16:54
  • The key thing to understand is that `Observable.Interval` is pretty much an "interval" timer - it specifies the interval (gap) between the processing of two values, not between starting points. – Enigmativity Jul 17 '15 at 01:44

0 Answers0