Created
November 4, 2014 16:38
-
-
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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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