Skip to content

Instantly share code, notes, and snippets.

@tomliversidge
Created April 10, 2017 21:14
Show Gist options
  • Save tomliversidge/9bc60e344008a9165c497a68931f8f93 to your computer and use it in GitHub Desktop.
Save tomliversidge/9bc60e344008a9165c497a68931f8f93 to your computer and use it in GitHub Desktop.
error
var props1 = Actor.FromProducer(() => new DoNothingActor())
.WithMailbox(() => new TestMailbox());
var localActor1 = Actor.SpawnNamed(props1, "local");
var props2 = Actor.FromProducer(() => new LocalActor(localActor1))
.WithMailbox(() => new TestMailbox());
var watcher = Actor.SpawnNamed(props2, "watcher");
localActor1.Stop();
public class LocalActor : IActor
{
private readonly PID _remoteActor;
private bool _terminateReceived;
public LocalActor(PID remoteActor)
{
_remoteActor = remoteActor;
}
public Task ReceiveAsync(IContext context)
{
switch (context.Message)
{
case Started msg:
context.Watch(_remoteActor);
break;
case string msg when msg == "?":
context.Sender.Tell(_terminateReceived);
break;
case Terminated msg:
_terminateReceived = true;
break;
}
return Actor.Done;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment