I have code similar to this.
IPruduceDemUpdates.Subscribe(update => DoUpdate(update));
But what I want to do is something like that.
IPruduceDemUpdates.Subscribe(update => if(NoDoUpadteIsRunning) DoUpdate(update));
So it ignores incoming updates, if the update method is already running. In addition, it should always execute the last update. No matter if it is the last update of the stream or the last for a period of time. Here an example timeline
- Update 1 starts
- Update 2 is ignored
- Update 3 is ignored
- Update 4 is ignored
- Update 1 finished
- Update 4 starts
- Update 4 finished
Edit
I have solution for skipping
IPruduceDemUpdates.Subscribe(update =>
{
if (_task == null || _task.IsCompleted || _task.IsCanceled || _task.IsFaulted)
_task = DoUpdate(update);
});
But I don't know how to be sure, that the last update will process.