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


C# ActorSystem.CreateActor方法代码示例

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


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

示例1: SimpleTestAskContX

        public void SimpleTestAskContX()
        {
            bool f = false;

            int res = 0;

            var acts = new ActorSystem();
            var act = acts.CreateActor<SimpleTestActor>();

            var m = new acttestmsg()
            {
                act = () =>
                {

                    return 10;
                },
                msg = "test message"
            };

            Task<int> tsk = null;
            tsk = act.Ask<int>((x) =>
               {
               res = x;
               if (tsk == null) return;
               if (tsk.IsCompleted) return;
               f = true;
               }, m);

            tsk.Wait();

            Assert.IsTrue(f);
            Assert.AreEqual(10, res);
            Assert.AreEqual(10, tsk.Result);
            Console.WriteLine("test complete");
        }
开发者ID:lebaon,项目名称:AEF,代码行数:35,代码来源:BasicTests.cs

示例2: PostStopEception

        public void PostStopEception()
        {
            var tl = new TestLogger();

            var actf = new ActorSystem(tl);
            var act = actf.CreateActor<PostStopFaultActor>();

            act.Ask<int>(new Action(() => { throw new Exception(); })).Wait();
            tl.setted = false;
            try
            {
                act.Ask<int>(new stopmsg()).Wait();
            }
            catch { }

            while (!tl.setted)
            {
                Thread.SpinWait(0);
            }

            Assert.AreEqual("ProcPostStopException", tl.mname);
            Assert.IsNotNull(tl.ex);

            Assert.AreEqual(tl.Act, act);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:25,代码来源:LogTests.cs

示例3: AllActorHasName

 public void AllActorHasName()
 {
     var actf = new ActorSystem();
     var act = actf.CreateActor<SimpleTestActor>();
     Assert.IsTrue(act.Name.Length > 0);
     Console.WriteLine("Created Actor name: {0}", act.Name);
 }
开发者ID:lebaon,项目名称:AEF,代码行数:7,代码来源:NameTests.cs

示例4: ExeptionInExProcEqualsExcalation

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

            var tsk1 = act1.Ask<ActorRef>(new createchildactormsg());
            tsk1.Wait();
            var act2 = tsk1.Result;

            var tsk = act1.Ask<int>(new seteh() { eh = () => { throw new Exception(); } });
            tsk.Wait();

            tsk = act2.Ask<int>(new acttestmsg() { act = () => { throw new Exception(); } });
            try { tsk.Wait(); }
            catch { }

            bool f = false;

            tsk = act2.Ask<int>(new getstate());
            try { tsk.Wait(); }
            catch { f = true; }

            Assert.IsTrue(f);

            f = false;

            tsk = act1.Ask<int>(new getstate());
            try { tsk.Wait(); }
            catch { f = true; }

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

示例5: MsgInStoppedActor

        public void MsgInStoppedActor()
        {
            var tl = new TestLogger();

            var actf = new ActorSystem(tl);
            var act = actf.CreateActor<PostStopFaultActor>();
            try
            {
                act.Ask<int>(new stopmsg()).Wait();
            }
            catch { }

            tl.setted = false;
            act.Ask<int>("fgh", 123);

            while (!tl.setted)
            {
                Thread.SpinWait(0);
            }

            Assert.AreEqual("fgh", tl.args[0]);
            Assert.AreEqual(123, tl.args[1]);
            Assert.AreEqual("ProcMsgInStoppedActor", tl.mname);
            Assert.AreEqual(tl.ReturnType, typeof(int));
            Assert.AreEqual(tl.Act, act);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:26,代码来源:LogTests.cs

示例6: ExProcStrategyIsRestart

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

            var tsk1 = act1.Ask<ActorRef>(new createchildactormsg());
            tsk1.Wait();
            var act2 = tsk1.Result;

            var tsk = act1.Ask<int>(new seteh() { eh = () => { return ExceptionDecision.Restart; } });
            tsk.Wait();

            tsk = act2.Ask<int>(new setstate() { x = 37 });
            tsk.Wait();

            tsk = act2.Ask<int>(new acttestmsg() { act = () => { throw new Exception(); } });
            try { tsk.Wait(); }
            catch { }

            bool f = false;

            f = false;

            tsk = act1.Ask<int>(new getstate());
            try { tsk.Wait(); }
            catch { f = true; }

            Assert.IsFalse(f);

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

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

示例7: ActorFullNameIsIerarhy

        public void ActorFullNameIsIerarhy()
        {
            var actf = new ActorSystem();
            var act = actf.CreateActor<IerarhyTestActor>("myactor");

            var act2 = act.Ask<ActorRef>(new createchildactormsg()).Result;

            Assert.AreEqual("\\user\\myactor\\child", act2.FullName);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:9,代码来源:NameTests.cs

示例8: AllActorHasParentTest

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

            var tsk = act.Ask<ActorRef>(new getparentmsg());
            tsk.Wait();

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

示例9: BlockedSelfStop

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

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

            tsk = act.Ask<int>(new getstate());
            tsk.Wait();
        }
开发者ID:lebaon,项目名称:AEF,代码行数:11,代码来源:ActorIerarhyTests.cs

示例10: ActorDontHaveSlashInName

        public void ActorDontHaveSlashInName()
        {
            bool f = false;
            var actf = new ActorSystem();
            try
            {
                var act = actf.CreateActor<SimpleTestActor>("\\");
            }
            catch { f = true; }

            Assert.IsTrue(f);
            f = false;
            try
            {
                var act = actf.CreateActor<SimpleTestActor>("/");
            }
            catch { f = true; }

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

示例11: FindActorByPath

        public void FindActorByPath()
        {
            var actf = new ActorSystem();
            var act = actf.CreateActor<IerarhyTestActor>("myactor");

            var act2 = act.Ask<ActorRef>(new createchildactormsg()).Result;

            var fact = actf.FindActorByPath("\\user\\myactor\\child");

            Assert.NotNull(fact);
            Assert.AreEqual(act2, fact);
        }
开发者ID:lebaon,项目名称:AEF,代码行数:12,代码来源:NameTests.cs

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

示例13: BlockedSelfRestart

        public void BlockedSelfRestart()
        {
            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 selfrestart());
            tsk.Wait();

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

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

示例14: CreateActorTest

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

            var tsk = act.Ask<ActorRef>(new crerateactormsg());
            tsk.Wait();

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

            var tsk2 = act2.Ask<int>(new acttestmsg() { msg = "test message", act = () => { return 10; } });
            tsk2.Wait();

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

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


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