protected override bool Receive(object message) { if (message is Messages.Msg) { _received++; if (_sent < _repeat) { _actor.Tell(message); _sent++; } else if (_received >= _repeat) { // Console.WriteLine("done {0}", Self.Path); _latch.SetResult(true); } return(true); } if (message is Messages.Run) { var msg = new Messages.Msg(); for (int i = 0; i < Math.Min(1000, _repeat); i++) { _actor.Tell(msg); _sent++; } return(true); } if (message is Messages.Started) { Sender.Tell(message); return(true); } return(false); }
public ClientAsyncActor(IActorRef actor, long repeat, TaskCompletionSource <bool> latch) { var received = 0L; var sent = 0L; ReceiveAsync <Messages.Msg>(async m => { received++; if (sent < repeat) { actor.Tell(m); sent++; } else if (received >= repeat) { latch.SetResult(true); } }); Receive <Messages.Run>(r => { var msg = new Messages.Msg(); for (int i = 0; i < Math.Min(1000, repeat); i++) { actor.Tell(msg); sent++; } }); Receive <Messages.Started>(s => Sender.Tell(s)); }