Skip to content

Instantly share code, notes, and snippets.

@davidgrenier
Created February 8, 2012 02:00
Show Gist options
  • Save davidgrenier/1764329 to your computer and use it in GitHub Desktop.
Save davidgrenier/1764329 to your computer and use it in GitHub Desktop.
PostAndAsyncReply
type MessageWithResponse =
| GetNextNumber of AsyncReplyChannel<int> * int
let inbox =
MailboxProcessor.Start <| fun inbox ->
async {
while true do
let! (GetNextNumber(channel, num)) = inbox.Receive()
channel.Reply (num + 1)
};;
inbox.PostAndReply (fun channel -> GetNextNumber(channel, 3)) // retourne 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment