Monday, May 31, 2010

F# barebone Agent


Agent = using message passing to avoid mutating state
type Downloader() =

let agent =
MailboxProcessor.Start(fun inbox ->
let rec loop() = async {
let msg=inbox.Receive()
do! Async.Sleep(5000)
return! loop()
}
loop()
)

member this.DowloadAll()=
while(true) do
agent.Post("test")

No comments: