Created
April 10, 2017 21:14
-
-
Save tomliversidge/9bc60e344008a9165c497a68931f8f93 to your computer and use it in GitHub Desktop.
error
This file contains hidden or 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
| 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