Skip to content

Instantly share code, notes, and snippets.

@rogeralsing
Forked from philiplaureano/helloactor.fsx
Last active July 28, 2017 07:40
Show Gist options
  • Save rogeralsing/7d950e152c1b7ba2d892260e37742cc1 to your computer and use it in GitHub Desktop.
Save rogeralsing/7d950e152c1b7ba2d892260e37742cc1 to your computer and use it in GitHub Desktop.
open System
open System.Threading.Tasks
open Proto
open Proto.Mailbox
type Actor with
static member SpawnFromFunc handler =
let wrapper = fun c ->
handler(c)
Task.FromResult(0)
Actor.FromFunc(wrapper) |> Actor.Spawn
[<EntryPoint>]
let main argv =
let handler =
fun (context : IContext) ->
match context.Message with
| :? string as s -> printfn "%s" s
| _ as o -> printfn "Unhandled message type: %s" (o.GetType().Name)
let pid = handler |> Actor.SpawnFromFunc
pid.Tell("Testing 1 2 3")
Console.WriteLine "Press ENTER to continue..."
Console.ReadLine() |> ignore
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment