當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。