Ok, after using System.Threading.Timer as suggested by SLaks, I've got this extremely simple snippet:
public sealed class CallBuffer : IDisposable
{
private readonly TimeSpan _timeSpan;
private readonly Timer _timer;
public CallBuffer(Action call, TimeSpan timeSpan)
{
_timeSpan = timeSpan;
_timer = new Timer(state => call());
}
public void Buffer()
{
_timer.Change(_timeSpan, TimeSpan.FromMilliseconds(-1));
}
void IDisposable.Dispose()
{
_timer.Dispose();
GC.SuppressFinalize(this);
}
}
Did I miss something here?
One note, is that it does not care about the UI thread (caller should pass proper invocation) and this allows to separate this code from the views.