當前位置: 首頁>>代碼示例>>C#>>正文


C# ActorSystem.StopActor方法代碼示例

本文整理匯總了C#中ActorSystem.StopActor方法的典型用法代碼示例。如果您正苦於以下問題:C# ActorSystem.StopActor方法的具體用法?C# ActorSystem.StopActor怎麽用?C# ActorSystem.StopActor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ActorSystem的用法示例。


在下文中一共展示了ActorSystem.StopActor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PostStopErrTest

        public void PostStopErrTest()
        {
            Exception e = null;
            var acts = new ActorSystem();
            var act = acts.CreateActor<RestartFaultActor>();
            try
            {
                acts.StopActor(act);
            }
            catch (Exception ex) { e = ex; }

            Assert.IsNull(e);
        }
開發者ID:lebaon,項目名稱:AEF,代碼行數:13,代碼來源:InActorTests.cs

示例2: ChildHasStopedOrRestartedOnlyByParent

        public void ChildHasStopedOrRestartedOnlyByParent()
        {
            var actf = new ActorSystem();
            var act1 = actf.CreateActor<IerarhyTestActorOvveride>();

            var tsk = act1.Ask<ActorRef>(new createchildactormsg());
            tsk.Wait();

            var act2 = tsk.Result;
            Assert.IsNotNull(act2);

            bool f = false;

            try
            {

                actf.StopActor(act2);
            }
            catch
            {
                f = true;
            }

            Assert.IsTrue(f);
            f = false;

            try
            {

                actf.RestartActor(act2);
            }
            catch
            {
                f = true;
            }

            Assert.IsTrue(f);
        }
開發者ID:lebaon,項目名稱:AEF,代碼行數:38,代碼來源:ActorIerarhyTests.cs

示例3: SimpleTestStopActor

        public void SimpleTestStopActor()
        {
            bool f = false;

            var acts = new ActorSystem();
            var act = acts.CreateActor<SimpleTestActor>();
            acts.StopActor(act);
            var m = new acttestmsg()
            {
                act = () =>
                {
                    f = true;
                    return 0;
                },
                msg = "test message"
            };

            var tsk = act.Ask<int>(m);
            try
            {
                tsk.Wait();
            }
            catch (AggregateException e) { }

            Assert.IsFalse(f);
            Assert.IsNotNull(tsk.Exception);
            Console.WriteLine("test complete");
        }
開發者ID:lebaon,項目名稱:AEF,代碼行數:28,代碼來源:BasicTests.cs

示例4: PostStopTest

        public void PostStopTest()
        {
            bool f = false;
            var acts = new ActorSystem();
            var act = acts.CreateActor<IntoTestActor>();

            var m = new poststoptestmsg() { poststop = () => { f = true; } };
            var tsk = act.Ask<int>(m);
            tsk.Wait();
            Assert.IsFalse(f);
            acts.StopActor(act);

            Assert.IsTrue(f);
        }
開發者ID:lebaon,項目名稱:AEF,代碼行數:14,代碼來源:InActorTests.cs

示例5: StopParentStoppingChilds

        public void StopParentStoppingChilds()
        {
            var actf = new ActorSystem();
            var act1 = actf.CreateActor<IerarhyTestActor>();

            var tsk = act1.Ask<ActorRef>(new createchildactormsg());
            tsk.Wait();

            var act2 = tsk.Result;
            Assert.IsNotNull(act2);

            actf.StopActor(act1);

            bool f = false;
            try
            {
                act1.Ask<int>(new acttestmsg()
                {
                    act = () => { return 0; }
                })
                    .Wait(100);
            }
            catch
            {
                f = true;
            }

            Assert.IsTrue(f);
            f = false;
            try
            {
                act2.Ask<int>(new acttestmsg()
                {
                    act = () => { return 0; }
                })
                    .Wait(100);
            }
            catch
            {
                f = true;
            }

            Assert.IsTrue(f);
        }
開發者ID:lebaon,項目名稱:AEF,代碼行數:44,代碼來源:ActorIerarhyTests.cs


注:本文中的ActorSystem.StopActor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。