If a batched set of changes is consumed on a different thread (UI thread in this case) from the producer (Threadpool thread) there is a race condition between the buffered changes being cleared and the consumer consuming the buffered change set, resulting in buffered changes being lost.
from BatchIf.cs...
var resume = bufferSelector.Where(shouldPause => !shouldPause)
.Subscribe(_ =>
{
paused = false;
//publish changes and clear buffer
if (buffer.Count == 0) return;
observer.OnNext(new ChangeSet<TObject, TKey>(buffer));
buffer.Clear(); <-- Race between this and the OnNext being consumed
//kill off timeout if required
timeoutSubscriber.Disposable = Disposable.Empty;
});
I am working on a fix for this
If a batched set of changes is consumed on a different thread (UI thread in this case) from the producer (Threadpool thread) there is a race condition between the buffered changes being cleared and the consumer consuming the buffered change set, resulting in buffered changes being lost.
from BatchIf.cs...
var resume = bufferSelector.Where(shouldPause => !shouldPause).Subscribe(_ =>{paused = false;//publish changes and clear bufferif (buffer.Count == 0) return;observer.OnNext(new ChangeSet<TObject, TKey>(buffer));buffer.Clear();<-- Race between this and the OnNext being consumed//kill off timeout if requiredtimeoutSubscriber.Disposable = Disposable.Empty;});I am working on a fix for this