using Akka;
using Akka.Actor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyAkka
{
class Program
{
public class PrintMyActorRefActor : UntypedActor
{
protected override void OnReceive(object message)
{
switch (message)
{
case "printit":
IActorRef secondRef = Context.ActorOf(Props.Empty, "second-actor");
Console.WriteLine($"Second: {secondRef}");
break;
}
}
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var firstRef = Sys.ActorOf(Props.Create<PrintMyActorRefActor>(), "first-actor");
Console.WriteLine($"First: {firstRef}");
firstRef.Tell("printit", ActorRefs.NoSender);
Console.ReadKey();
}
}
}
var sys = ActorSystem.Create("tutorial-actor-system");
var firstRef = sys.ActorOf(Props.Create<PrintMyActorRefActor>(), "first-actor");
actor.Tell(something)
, I need to put a Thread.Sleep()
or a await Task.Delay()
, which doesn’t look a proper way of testing.. unless I’m missing an existing way to accomplish it. I wouldn’t like to add reply messages just to be able to test the code