Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

다만 부모에게 발생한 예외를 자식에게 전가시키지 않습니다. ( 예외처리모델에 더 상세하게 설명)



Code Block
languagescalac#
themeEmacs
titleActor 중지
linenumberstrue
    public class StartStopActor1 : ReceiveActor
    {
        private ILoggingAdapter log = Context.GetLogger();

        public StartStopActor1()
        {
            Receive<string>(message => {
                if (message == "stop")
                {
                    Context.Stop(Self);
                }                
            });            
        }

        protected override void PreStart()
        {
            log.Info("first started");
            Context.ActorOf<StartStopActor2>("second");
        }

        protected override void PostStop()
        {
            log.Info("first stopped");
        }

    }

    public class StartStopActor2 : ReceiveActor
    {
        private ILoggingAdapter log = Context.GetLogger();

        public StartStopActor2()
        {
            Receive<string>(message => {                
            });            
        }

        protected override void PreStart()
        {
            log.Info("second started");

        }

        protected override void PostStop()
        {
            log.Info("second stopped");
        }

    }


	IActorRef myActor = actorSystem.ActorOf<StartStopActor1 >("myactor");
	myActor.Tell("stop");

//OutPut
//first started
//second started
//second stopped
//first stopped

...