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


C# Actor.Start方法代码示例

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


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

示例1: Spawn

        public static ActorReference Spawn(this Silo silo, string processName, Action<object, Sender, Actor> action)
        {
            var task = Task.Run(() =>
                {
                    var serializer = silo.MessageSerializerFactory.GetNewSerializer();
                    using (var actor = new Actor(silo.Context, serializer, processName, processName, action))
                    {
                        actor.Start();
                    }
                });

            return new ActorReference { ActorReferenceTask = task, Address = processName, ActorFactory = silo.ActorFactory, MessageSerializerFactory = silo.MessageSerializerFactory};
        }
开发者ID:yonglehou,项目名称:Daytona,代码行数:13,代码来源:FrameworkExtensions.cs

示例2: Start

        public void Start()
        {
            Actor a = new Actor(() =>
            {
                var nums = Enumerable.Range(1, __count).ToList();
                nums.ForEach(
                    n =>
                    {
                        System.Threading.Thread.Sleep(1000);
                        int recv = 0;
                        var sender = Actor.Self().receive<int>(ref recv, 0);
                        Console.WriteLine(string.Format("actor {0} received {1}", Actor.Self().Name, recv));
                        recv++;
                        Actor.Self().send<int>(sender, recv, 0);
                    });
            }) { Name = "a" };

            Actor b = new Actor(() =>
            {

                int recv = 0;
                var nums = Enumerable.Range(1, __count).ToList();
                nums.ForEach(n =>
                {

                    Actor.Self().send<int>(a, recv, 0);
                    System.Threading.Thread.Sleep(1000);
                    var sender = Actor.Self().receive<int>(ref recv, 0);
                    Console.WriteLine(string.Format("actor {0} received {1}", Actor.Self().Name, recv));
                    recv++;

                });

            }) { Name = "b" };

            a.Start();
            b.Start();
        }
开发者ID:kotbegemot,项目名称:actor-cpp,代码行数:38,代码来源:PingPong.cs

示例3: CallKillMe

        public void CallKillMe()
        {
            using (var context = NetMQContext.Create())
            {
                using (var exchange = new Exchange(context))
                {
                    exchange.Start();
                    using (var customer = new Actor<Customer>(context, new BinarySerializer()))
                    {
                        Thread.Sleep(300);
                        Task.Run(() => customer.Start());
                    }

                    exchange.Stop(true);
                }
            }
        }
开发者ID:yonglehou,项目名称:Daytona,代码行数:17,代码来源:ActorTests.cs


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