This project is read-only.
Use mail box processor to process simple message

Category:
Mailbox Processor
Description: Use mail box processor to process simple message
Code:
type Agent<'T> = MailboxProcessor<'T>

let agentSample0() =
let agent =
Agent.Start(fun inbox ->
async { for i in [1..3] do
let! msg = inbox.Receive()
printfn "got message '%s'" msg } )
printfn "because the message is running on the background thread, please see the result at the console window behind"
agent.Post("msg1");
agent.Post("msg2");
agent.Post("msg3");

Execution Result:
because the message is running on the background thread, please see the result at the console window behind

Last edited Sep 14, 2011 at 4:13 AM by ttliu2000, version 1

Comments

No comments yet.