Skip to content

Instantly share code, notes, and snippets.

@Kimserey
Created December 21, 2015 06:37
Show Gist options
  • Save Kimserey/e163a825c0a88a91cf1f to your computer and use it in GitHub Desktop.
Save Kimserey/e163a825c0a88a91cf1f to your computer and use it in GitHub Desktop.
Mailbox processor sample
type OperationTest =
| Increment
| Decrement
let agent = MailboxProcessor.Start(fun inbox ->
let rec loop state: Async<unit> = async {
let! msg = inbox.Receive()
match msg with
| Increment -> return! loop (state + 1)
| Decrement -> return! loop (state - 1)
}
loop 0)
agent.Post (OperationTest.Increment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment