Tutorial by Examples

Let's first create a simple "Hello world!" MailboxProcessor which processes one type of message and prints greetings. You'll need the message type. It can be anything, but Discriminated Unions are a natural choice here as they list all the possible cases on one place and you can easily us...
Mailbox processors can be used to manage mutable state in a transparent and thread-safe way. Let's build a simple counter. // Increment or decrement by one. type CounterMessage = | Increment | Decrement let createProcessor initialState = MailboxProcessor<CounterMessage>.Sta...
You can asynchronously return a value for each processed message if you send an AsyncReplyChannel<'a> as part of the message. type MessageWithResponse = Message of InputData * AsyncReplyChannel<OutputData> Then the mailbox processor can use this channel when processing the message to...
You can use Scan or TryScan methods to look for specific messages in the queue and process them regardless of how many messages are before them. Both methods look at the messages in the queue in the order they arrived and will look for a specified message (up until optional timeout). In case there i...

Page 1 of 1