当前位置: 首页>>代码示例>>C#>>正文


C# ActorSystem.RestartActor方法代码示例

本文整理汇总了C#中ActorSystem.RestartActor方法的典型用法代码示例。如果您正苦于以下问题:C# ActorSystem.RestartActor方法的具体用法?C# ActorSystem.RestartActor怎么用?C# ActorSystem.RestartActor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActorSystem的用法示例。


在下文中一共展示了ActorSystem.RestartActor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostRestartErrTest

        public void PostRestartErrTest()
        {
            Exception e = null;
            var acts = new ActorSystem();

            var act = acts.CreateActor<RestartFaultActor>();
            try
            {
                acts.RestartActor(act);
            }
            catch (Exception ex) { e = ex; }

            Assert.IsNotNull(e);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:14,代码来源:InActorTests.cs

示例2: PostRestartTest

        public void PostRestartTest()
        {
            var acts = new ActorSystem();
            var act = acts.CreateActor<IntoTestActor>();

            var tsk = act.Ask<int>(new statemsg());
            tsk.Wait();

            Assert.AreEqual(10, tsk.Result);

            acts.RestartActor(act);

            tsk = act.Ask<int>(new statemsg());
            tsk.Wait();

            Assert.AreEqual(15, tsk.Result);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:17,代码来源:InActorTests.cs

示例3: SimpleTestRestartActor

        public void SimpleTestRestartActor()
        {
            var acts = new ActorSystem();
            var act = acts.CreateActor<SimpleTestActor>();

            var m = new statemsg() { newstate = 10 };

            var tsk = act.Ask<int>(m);
            tsk.Wait();

            m = new statemsg() { newstate = 10 };

            tsk = act.Ask<int>(m);
            tsk.Wait();

            Assert.AreEqual(10, tsk.Result);

            acts.RestartActor(act);

            m = new statemsg() { newstate = 10 };

            tsk = act.Ask<int>(m);
            tsk.Wait();

            Assert.AreEqual(0, tsk.Result);

            Console.WriteLine("test complete");
        }
开发者ID:lebaon,项目名称:AEF,代码行数:28,代码来源:BasicTests.cs

示例4: 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

示例5: RestartParentWithUserPredRestartNotStoppingChilds

        public void RestartParentWithUserPredRestartNotStoppingChilds()
        {
            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);

            actf.RestartActor(act1);

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

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

            Assert.IsFalse(f);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:44,代码来源:ActorIerarhyTests.cs

示例6: PredRestartTest

        public void PredRestartTest()
        {
            var actf = new ActorSystem();
            var act = actf.CreateActor<PredRestartTestActor>();

            var tsk = act.Ask<int>(new setstate() { x = 20 });
            tsk.Wait();

            tsk = act.Ask<int>(new getstate());
            tsk.Wait();

            Assert.AreEqual(20, tsk.Result);

            int savestate = 0;
            tsk = act.Ask<int>(new setpra()
            {
                pra = (state) =>
                {

                    savestate = state;
                }
            });
            tsk.Wait();

            actf.RestartActor(act);

            Assert.AreEqual(20, savestate);

            tsk = act.Ask<int>(new getstate());
            tsk.Wait();

            Assert.AreEqual(0, tsk.Result);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:33,代码来源:ActorIerarhyTests.cs

示例7: FaultOnRestartStoppingActor

        public void FaultOnRestartStoppingActor()
        {
            bool f = false;
            var acts = new ActorSystem();

            var act = acts.CreateActor<RestartFaultActor>();
            try
            {
                acts.RestartActor(act);
            }
            catch  { }

            var tsk = act.Ask<int>(new acttestmsg() { act = () => { return 0; } });
            try { tsk.Wait(); }
            catch { f = true; }

            Assert.IsTrue(f);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:18,代码来源:ExceptionProcTests.cs


注:本文中的ActorSystem.RestartActor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。