Skip to content

Instantly share code, notes, and snippets.

@philiplaureano
Created July 28, 2017 06:37
Show Gist options
  • Save philiplaureano/b42b1a4b6c0a0ab3e39e43927c86509a to your computer and use it in GitHub Desktop.
Save philiplaureano/b42b1a4b6c0a0ab3e39e43927c86509a 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 =
Actor.FromFunc(fun c-> handler(c)) |> 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)
Task.CompletedTask
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