Esempio n. 1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            btnSend.Enabled = false;

            foreach (var el in names)
            {
                var props = Props.Create(() => new WorkerActor((int)el[0], 2000, _logger));

                // el je ime actora
                var actor = Program.System.ActorOf(props, el);

                _actors.Add(el, actor);
            }

            foreach (var actor in _actors.Values)
            {
                // dovavimo listu actora koje trenutni actor mora poznavati
                List <IActorRef> others = _actors.Values.Where(x => x.Path != actor.Path).ToList();

                // kreiramo poruku
                WorkerStart msg = new WorkerStart(others);

                // posaljimo trenutnom actoru poruku da se pokrene
                actor.Tell(msg);
            }
        }
        private void ProcessStart(WorkerStart msg, int sleep)
        {
            _others = msg.OtherActors;
            _sleep  = sleep;

            // Mijenja ponasanje actora na nacin da
            Become(NewBehaviour);

            // Pricekat cemo "sleep" prije nego posaljemo novu poruku
            Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromMilliseconds(sleep), Self, new Loop(), Self);
        }