Skip to content

Instantly share code, notes, and snippets.

@clemensv
Last active January 3, 2017 14:11
Show Gist options
  • Save clemensv/9953010 to your computer and use it in GitHub Desktop.
Save clemensv/9953010 to your computer and use it in GitHub Desktop.
However often you call me, I'm only going to flush every 200msec from the first flush call
Task flushingTask = null;
public override Task FlushAsync(CancellationToken cancellationToken)
{
Interlocked.CompareExchange(
ref flushingTask,
Task.Delay(200, cancellationToken).ContinueWith(
async (t) =>
{
await write.FlushAsync(cancellationToken);
Interlocked.Exchange(ref flushingTask, null);
},
cancellationToken),
null);
return Task.FromResult(true);
}
@GoharKhan
Copy link

:P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment