Ejemplo n.º 1
0
        /// <summary>
        /// Causes the Actor to become a different kind of actor.
        /// This has little if any use with the current design
        /// because messages are delivered to individual OnReceive()
        /// methods.
        /// </summary>
        /// <param name="receive">the Receive to which messages are dispatched</param>
        /// <param name="discardOld">the bool that if set causes an Unbecome() before the Become()</param>
        public void Become(Receive receive, bool discardOld = true)
        {
            if (discardOld)
            {
                Unbecome();
            }

            Receive = receive;

            Receivers.Push(receive);

            Channel.ClearSubscribers();

            Channel.Subscribe(Fiber, GetOnReceiveDelegate());
        }