Created
December 21, 2015 06:37
-
-
Save Kimserey/e163a825c0a88a91cf1f to your computer and use it in GitHub Desktop.
Mailbox processor sample
This file contains hidden or 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
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