Skip to content

Instantly share code, notes, and snippets.

@yreynhout
Forked from clemensv/gist:9953010
Created April 3, 2014 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yreynhout/9953104 to your computer and use it in GitHub Desktop.
Save yreynhout/9953104 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment