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


C# Actor.StartAllActors方法代码示例

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


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

示例1: RunSubscriber

       private Task RunSubscriber(NetMQContext context)
       {
            using (NetMQSocket syncClient = context.CreateRequestSocket())
            {
                syncClient.Connect(Pipe.PubSubControlBackAddressClient);
                syncClient.Send(string.Empty);
                syncClient.Receive();
                
                var actions = new Dictionary<string, Delegate>();
                actions.Add("MethodInfo", TestActors);
                actions.Add("ShutDownAllActors", ShutDownAllActors);

                using (var actor = new Actor<Order>(context, new BinarySerializer()))
                {
                    actor.RegisterActor(
                        "Display",
                        string.Empty,
                        "outRoute",
                        null,
                        new BinarySerializer(),
                        new DefaultSerializer(Exchange.ControlChannelEncoding),
                        actions);

                    actor.StartAllActors();
                }               
            }    

            return null;
        }
开发者ID:yonglehou,项目名称:Daytona,代码行数:29,代码来源:ActorTests.cs

示例2: SendFiveMessageOfTypeConfigureActorToProcess

        public void SendFiveMessageOfTypeConfigureActorToProcess()
        {
             string input = string.Empty;
            string expectedAddress = "XXXXxxxx";
            string message = string.Empty;

            using (var context = ZmqContext.Create())
            {
                var pipe = new Pipe();
                pipe.Start(context);
                using (var pub = Helper.GetConnectedPublishSocket(context))
                {
                    using (var sub = Helper.GetConnectedSubscribeSocket(context))
                    {
                        using (var actor = new Actor(context))
                        {
                            ISerializer serializer = new Serializer(Encoding.Unicode);
                            actor.RegisterActor<Customer>("Basic", expectedAddress, "OutRoute", serializer, (Message, InRoute, OutRoute, Socket, Actor) =>
                            {
                                var customer = (Customer)Message;
                                if (!Actor.PropertyBag.ContainsKey("Count"))
                                {
                                    Actor.PropertyBag.Add("Count", "0");
                                }
                                var count = int.Parse(Actor.PropertyBag["Count"]);
                                count++;
                                Actor.PropertyBag["Count"] = count.ToString();

                                //Assert.AreEqual(cust.Firstname, customer.Firstname);
                                Helper.SendOneSimpleMessage("log", customer.Firstname + " " + customer.Lastname + " " + " Count " + Actor.PropertyBag["Count"], Socket);
                            }).RegisterActor("Logger", "log", (Message, InRoute) =>
                                {
                                    Helper.Writeline(Message);
                                });
                            actor.StartAllActors();

                            Task.Delay(5000);

                            for (int i = 0; i < 5; i++)
                            {
                                ISerializer serializer2 = new Serializer(Encoding.Unicode);
                                Customer cust = new Customer();
                                cust.Firstname = "John" + i.ToString();
                                cust.Lastname = "Wilson" + i.ToString();

                                Helper.SendOneMessageOfType<Customer>(expectedAddress, cust, serializer2, pub);
                            }

                            Helper.SendOneSimpleMessage(expectedAddress, "Stop", pub);
                            Task.Delay(5000);
                        }
                    }
                }
                pipe.Exit();
            }
        }
开发者ID:nka1,项目名称:Daytona,代码行数:56,代码来源:PipeTests.cs

示例3: Main

        static void Main(string[] args)
        {
            //    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            //    var directoryInfo = new DirectoryInfo(Environment.CurrentDirectory);
            //    var Files = directoryInfo.GetFiles();
            //    var path = Environment.CurrentDirectory + @"\NProxy.Core.dll";
            //    var assembly = Assembly.LoadFrom(path);

            Console.CancelKeyPress += new ConsoleCancelEventHandler(ConsoleCancelHandler);
            var binarySerializer = new BinarySerializer();
            var useActor = true;

            using (var context = NetMQContext.Create())
            {
                //if (!useActor)
                //{
                //    var subscriber = context.CreateSubscriberSocket();
                //    subscriber.Connect(Pipe.SubscribeAddressClient);
                //    subscriber.Subscribe(string.Empty);
                //    while (!interrupted)
                //    {
                //        var frame = subscriber.ReceiveFrame();
                //        try
                //        {
                //            Console.WriteLine(binarySerializer.Deserializer(frame, typeof(string)));
                //        }
                //        catch (Exception)
                //        {
                //        }

                //        while (subscriber.ReceiveMore)
                //        {
                //            var frame1 = subscriber.ReceiveFrame();
                //        }
                //    }
                //}
                //else
                //{
                using (var actorFactory = new Actor<Silo>(context, new BinarySerializer(), string.Empty))
                {
                    actorFactory.RegisterActor(
                        "Display",
                        "",
                        "outRoute",
                        new BinarySerializer(),
                        new DefaultSerializer(Exchange.ControlChannelEncoding),
                        (address, methodinfo, parameters, actor) =>
                            {
                                var firstParameter = string.Empty;
                                try
                                {
                                    firstParameter = parameters[0].ToString();
                                }
                                catch (Exception)
                                {
                                }

                                Console.WriteLine("Address: {0}, {1}", address, firstParameter);
                            });
                    actorFactory.StartAllActors();
                    Console.WriteLine("yada ");

                    while (!interrupted)
                    {
                        Console.ReadLine();
                    }
                }
                //}
            }
        }
开发者ID:yonglehou,项目名称:Daytona,代码行数:70,代码来源:Program.cs

示例4: SendOneMessageOfTypeConfigureActorToProcess

        public void SendOneMessageOfTypeConfigureActorToProcess()
        {
            using (var pipeContext = ZmqContext.Create())
            {
                var pipe = new Pipe();
                var task2 = Task.Run(() =>
                    {
                        pipe.Start(pipeContext);
                    });

                var task = Task.Run(() =>
                    {
                        string input = string.Empty;
                        string expectedAddress = "XXXXxxxx";
                        string message = string.Empty;

                        using (var context = ZmqContext.Create())
                        {

                            using (var pub = Helper.GetConnectedPublishSocket(context))
                            {
                                //using (var sub = GetConnectedSubscribeSocket(context))
                                //{
                                ISerializer serializer = new Serializer(Encoding.Unicode);
                                Customer cust = new Customer();
                                cust.Firstname = "Johnx";
                                cust.Lastname = "Wilson";

                                using (var actor = new Actor(context))
                                {
                                    actor.RegisterActor<Customer>("Basic", expectedAddress, "OutRoute", serializer, (Message, InRoute, OutRoute, Socket, Actor) =>
                                        {
                                            var customer = (Customer)Message;
                                            Assert.AreEqual(cust.Firstname, customer.Firstname);
                                            Helper.Writeline(customer.Firstname, @"c:\dev\xx.log");
                                        });
                                    actor.StartAllActors();

                                    Thread.Sleep(0);
                                }

                                for (int i = 0; i < 10; i++)
                                {
                                    cust.Firstname = i.ToString();
                                    Helper.SendOneMessageOfType<Customer>(expectedAddress, cust, serializer, pub);
                                    Thread.Sleep(0);
                                }
                                Helper.SendOneSimpleMessage(expectedAddress, "stop", pub);
                                Thread.Sleep(0);
                            }
                            //pipe.Exit();
                            //Thread.Sleep(0);
                        }
                    });
                Task.WaitAll(task, task2);
                pipe.Exit();
            }
        }
开发者ID:nka1,项目名称:Daytona,代码行数:58,代码来源:PipeTests.cs


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