37
1
using Akka.Actor;
2
using Akka.Configuration;
3
using System;
4
using System.Threading;
5
6
public class Program
7
{
8
public static void Main()
9
{
10
// this configuration is required ony in .NET Fiddle
11
var config = ConfigurationFactory.ParseString(@"akka.actor.default-dispatcher { type = ""Akka.Dispatch.TaskDispatcherConfigurator""}");
12
13
var system = ActorSystem.Create("Sample", config);
14
15
var actor = system.ActorOf<PingPongActor>();
16
17
for (var i = 0; i < 4; i++)
18
actor.Tell(i);
19
20
// alow some time for .NET Fiddle to flush
21
Thread.Sleep(1000);
22
}
23
24
public class PingPongActor : UntypedActor
25
{
26
protected override void OnReceive(object m1)
27
{
28
Console.WriteLine("Ping " + m1);
29
30
BecomeStacked(m2 => {
31
Console.WriteLine("Pong " + m2);
32
UnbecomeStacked();
33
});
34
}
35
}
36
}
37
Cached Result