Skip to content

Instantly share code, notes, and snippets.

@rofr
Created November 4, 2014 16:38
Show Gist options
  • Save rofr/4f784e57aed0e62e0668 to your computer and use it in GitHub Desktop.
Save rofr/4f784e57aed0e62e0668 to your computer and use it in GitHub Desktop.
Using WriteOnceBlock from TPL dataflow? There's got to be a better way!
public async Task<R> ExecuteAsync<R>(Command<M, R> command)
{
var completion = new WriteOnceBlock<object>(_ => _);
_commandQueue.PublishEvent((e, i) =>
{
e.Transaction = command;
e.Result = completion;
return e;
});
return (R) await completion.ReceiveAsync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment