I have a problem with rewriting following Akka.Net actor from C# to F#:
public class Listener : ReceiveActor
{
public Listener()
{
Receive<Messages.Shutdown>(s =>
{
Console.WriteLine($"shutdown {s.Duration}");
Context.System.Terminate();
});
}
}
Actor should handle only Shutdown message by terminating actor system. I tried to reimplement it like this:
type Listener() =
inherit ReceiveActor()
do
base.Receive<Messages>(fun m ->
match m with
| Shutdown(duration) ->
printf "shutdown %s" (duration.ToString())
base.Context.System.Terminate()
true
| _ -> false)
but there is a complation error in line base.Context.System.Terminate()
saying Property 'Context' is static
. What is wrong with this code? Why can't I access static property of a baseclass? Is it because this code is in lambda expresion (fun)? Or because it is in constructor (do)?