-
-
Save rogeralsing/7d950e152c1b7ba2d892260e37742cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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