示例#1
0
        private void Running(Job[] queue)
        {
            #region Upon Get append a job to the queue and keep running

            Receive<Get>(msg => Become(() => EnqueueJob(queue, new Job {Client = Sender, Url = msg.Url})));

            #endregion

            #region Upon Controller.Result ship the result to the Client and run the next job (if any)

            Receive<Controller.Result>(msg => {
                var job = queue.First();
                job.Client.Tell(new Result {Url = job.Url, Links = msg.Links});
                Context.Stop(Sender);
                Become(() => RunNext(queue.Skip(1).ToArray()));
            });

            #endregion
        }