Saturday, 15 August 2015

c# - Ignore incoming stream updates if last callback hasn't finished yet -



c# - Ignore incoming stream updates if last callback hasn't finished yet -

i have code similar this.

ipruducedemupdates.subscribe(update => doupdate(update));

but want that.

ipruducedemupdates.subscribe(update => if(nodoupadteisrunning) doupdate(update));

so ignores incoming updates, if update method running. in addition, should execute lastly update. no matter if lastly update of stream or lastly period of time. here illustration timeline

update 1 starts update 2 ignored update 3 ignored update 4 ignored update 1 finished update 4 starts update 4 finished edit

i have solution skipping

ipruducedemupdates.subscribe(update => { if (_task == null || _task.iscompleted || _task.iscanceled || _task.isfaulted) _task = doupdate(update); });

but don't know how sure, lastly update process.

if doupdate synchronous (which appears in case), can utilize bufferintrospective rxx. want:

iproducedemupdates .bufferintrospective() .where(items => items.count > 0) // ignore empty buffers .select(items => items[items.count - 1]) // ignore lastly item in buffer .subscribe(doupdate);

c# system.reactive

No comments:

Post a Comment