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


C# ActorSystem.AwaitTermination方法代码示例

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


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

示例1: Main

        private static void Main(string[] args)
        {
            ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem in remote process");
            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");

            MovieStreamingActorSystem.AwaitTermination();
        }
开发者ID:jozbone,项目名称:akkademos,代码行数:7,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            // initialize MyActorSystem
            MyActorSystem = ActorSystem.Create("MyActorSystem");

            // time to make your first actors!
            var consoleWriterActor = MyActorSystem.ActorOf(Props.Create<ConsoleWriterActor>(), "MyConsoleWriter"); // Generic syntax

            // make tailCoordinatorActor
            Props tailCoordinatorProps = Props.Create(() => new TailCoordinatorActor());
            var tailCoordinatorActor = MyActorSystem.ActorOf(tailCoordinatorProps, "tailCoordinatorActor");

            // pass tailCoordinatorActor to fileValidatorActorProps (just adding one extra arg)
            Props fileValidatorActorProps = Props.Create(() => new FileValidatorActor(consoleWriterActor));
            var validationActor = MyActorSystem.ActorOf(fileValidatorActorProps, "validationActor");


            var consoleReaderActor = MyActorSystem.ActorOf(Props.Create(() => new ConsoleReaderActor()), "MyConsoleReader");

            // tell console reader to begin
            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // Fake start with 
            validationActor.Tell(@"c:\MyFile.txt");

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:ymccready,项目名称:akka-bootcamp,代码行数:28,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            var config =
                ConfigurationFactory.ParseString(
                    File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "akka.config")));

            // make actor system
            MyActorSystem = ActorSystem.Create("MyActorSystem", config);

            // create top-level actors within the actor system
            Props consoleWriterProps = Props.Create<ConsoleWriterActor>();
            IActorRef consoleWriterActor = MyActorSystem.ActorOf(consoleWriterProps, "consoleWriterActor");

            Props tailCoordinatorProps = Props.Create(() => new TailCoordinatorActor());
            IActorRef tailCoordinatorActor = MyActorSystem.ActorOf(tailCoordinatorProps, "tailCoordinatorActor");

            Props fileValidatorActorProps = Props.Create(() => new FileValidatorActor(consoleWriterActor));
            IActorRef fileValidatorActor = MyActorSystem.ActorOf(fileValidatorActorProps, "validationActor");

            Props consoleReaderProps = Props.Create<ConsoleReaderActor>();
            IActorRef consoleReaderActor = MyActorSystem.ActorOf(consoleReaderProps, "consoleReaderActor");

            // begin processing
            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:sachabarber,项目名称:AkkaWintail,代码行数:28,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            // initialize MyActorSystem
            MyActorSystem = ActorSystem.Create("MyActorSystem");

            // make consoleWriterActor
            var consoleWriterProps = Props.Create(() => new ConsoleWriterActor());
            var consoleWriterActor = MyActorSystem.ActorOf(consoleWriterProps, "consoleWriterActor");

            // make tailCoordinatorActor
            var tailCoordinatorProps = Props.Create(() => new TailCoordinatorActor());
            var tailCoordinatorActor = MyActorSystem.ActorOf(tailCoordinatorProps, "tailCoordinatorActor");

            // make fileValidatorActor, pass consoleWriterActor and tailCoordinatorActor to fileValidatorActorProps
            var validationActorProps = Props.Create(() => new FileValidationActor(consoleWriterActor));
            var validationActor = MyActorSystem.ActorOf(validationActorProps, "validationActor");

            // make consoleReaderActor, pass validationActor to consoleReaderProps
            var consoleReaderProps = Props.Create(() => new ConsoleReaderActor());
            var consoleReaderActor = MyActorSystem.ActorOf(consoleReaderProps, "consoleReaderActor");

            // tell console reader to begin
            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:mi-tettamanti,项目名称:akka-bootcamp,代码行数:27,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            // initialize MyActorSystem
            MyActorSystem = ActorSystem.Create("MyActorSystem");

            // DEMO to show that typeof() is valid but dangerous
            //Props fakeActorProps = Props.Create(typeof(FakeActor));
            //IActorRef fakeActor = MyActorSystem.ActorOf(fakeActorProps, "fakeActor");

            Props consoleWriterProps = Props.Create<ConsoleWriterActor>();
            IActorRef consoleWriterActor = MyActorSystem.ActorOf(consoleWriterProps, "consoleWriterActor");

            Props tailCoordinatorActorProps = Props.Create(() => new TailCoordinatorActor());
            IActorRef tailCoordinatorActor = MyActorSystem.ActorOf(tailCoordinatorActorProps, "tailCoordinatorActor");

            // pass tailCoordinatorActor to fileValidatorActorProps (just adding one extra arg)
            Props fileValidatorActorProps = Props.Create(() => new FileValidatorActor(consoleWriterActor));
            IActorRef validationActor = MyActorSystem.ActorOf(fileValidatorActorProps, "validationActor");

            Props consoleReaderProps = Props.Create<ConsoleReaderActor>();
            IActorRef consoleReaderActor = MyActorSystem.ActorOf(consoleReaderProps, "consoleReaderActor");

            // tell console reader to begin
            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();

            Console.ReadKey();
        }
开发者ID:gunnarlr,项目名称:akka-bootcamp,代码行数:30,代码来源:Program.cs

示例6: Main

        private static void Main()
        {
            ConfigureLogging();

            LogTo.Debug($"Creating ActorSystem '{ActorSystemName}'.");
            _actorSystem = ActorSystem.Create(ActorSystemName);

            LogTo.Debug($"Creating Props '{nameof(ProductsActor)}'.");
            var props = Props.Create<ProductsActor>();

            LogTo.Debug($"Creating ActorOf '{nameof(ProductsActor)}'.");
            var products = _actorSystem.ActorOf(props);

            LogTo.Information("Adding products.");
            products.Tell(new AddProduct("Product 1"));
            products.Tell(new AddProduct("Product 2"));

            LogTo.Debug("Stopping products actor.");
            products.GracefulStop(TimeSpan.FromMinutes(1)).Wait();
            LogTo.Debug("Stopped products actor.");

            LogTo.Debug("Shutting down ActorSystem");
            _actorSystem.Shutdown();

            LogTo.Debug("Waiting for ActorSystem to complete shutdown.");
            _actorSystem.AwaitTermination();

            LogTo.Information("Finished shopping :-)");
        }
开发者ID:TimMurphy,项目名称:shop-with-akka.net,代码行数:29,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            // initialize MyActorSystem
            // YOU NEED TO FILL IN HERE
            MyActorSystem = ActorSystem.Create("MyActorSystem");

            // time to make your first actors!

            var consoleWriterProps = Props.Create(() => new ConsoleWriterActor());
            var consoleWriterActor = MyActorSystem.ActorOf(consoleWriterProps, "consoleWriterActor");

            var tailCoordinatorActor = MyActorSystem.ActorOf(Props.Create<TailCoordinatorActor>(), "tailCoordinatorActor");

            var validationActorProps = Props.Create(() => new FileValidatorActor(consoleWriterActor));
            var validationActor = MyActorSystem.ActorOf(validationActorProps, "validationActor");
            var consoleReaderProps = Props.Create<ConsoleReaderActor>();
            var readerActor = MyActorSystem.ActorOf(consoleReaderProps, "consoleReaderActor");

            // tell console reader to begin
            //YOU NEED TO FILL IN HERE
            readerActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:BredStik,项目名称:akka-bootcamp,代码行数:25,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {
            // make an actor system 
            MyActorSystem = ActorSystem.Create("MyActorSystem");

            // this is here to show you what NOT to do
            // this approach to props has no type safety
            // it will compile, but can easily blow up in your face at runtime :(
            // UNCOMMENT THE BELOW TWO LINES, BUILD THE SOLUTION, AND THEN TRY TO RUN IT TO SEE
            //Props fakeActorProps = Props.Create(typeof(FakeActor));
            //IActorRef fakeActor = MyActorSystem.ActorOf(fakeActorProps, "fakeActor");

            // set up actors, using props (split props onto own line so easier to read)
            Props consoleWriterProps = Props.Create<ConsoleWriterActor>();
            IActorRef consoleWriterActor = MyActorSystem.ActorOf(consoleWriterProps, "consoleWriterActor");

            Props validationActorProps = Props.Create(() => new ValidationActor(consoleWriterActor));
            IActorRef validationActor = MyActorSystem.ActorOf(validationActorProps, "validationActor");
            
            Props consoleReaderProps = Props.Create<ConsoleReaderActor>(validationActor);
            IActorRef consoleReaderActor = MyActorSystem.ActorOf(consoleReaderProps, "consoleReaderActor");

            // tell console reader to begin
            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:CActor,项目名称:akka-bootcamp,代码行数:28,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem2");
            Console.WriteLine("Actor system created.");

            Props props = Props.Create<PlaybackActor>();
            IActorRef actorRef = MovieStreamingActorSystem.ActorOf(props, "PlaybackActor");

            actorRef.Tell(new PlayMovieMessage("Akka.NET: The Movie", 42));
            actorRef.Tell(new PlayMovieMessage("Partial Recall", 99));
            actorRef.Tell(new PlayMovieMessage("Boolean Lies", 77));
            actorRef.Tell(new PlayMovieMessage("Codenan the Destroyer", 1));

            actorRef.Tell(PoisonPill.Instance);

            //Console.WriteLine("Press any key to start the shutdown of the system");
            Console.ReadKey();

            // Tell actor system (and all child actors) to shutdown
            MovieStreamingActorSystem.Shutdown();
            // Wait for actor system to finish shutting down
            MovieStreamingActorSystem.AwaitTermination();
            Console.WriteLine("Actor system has shutdown");

            Console.ReadKey();
        }
开发者ID:jozbone,项目名称:akkademos,代码行数:26,代码来源:Program.cs

示例10: Main

        static void Main(string[] args)
        {
            // Akka prefers creation of objects via factories
            // this is due to the fact that internally Akka does a lot of system internally
            UntypedActorSystem = ActorSystem.Create("UntypedActorSystem");
            Console.WriteLine("Actor system created");

            // Akka uses the movie industry to name a few items
            // To create an Actor you use the Props class
            Props whatsMyTypeAgainProps = Props.Create<WhatsMyTypeAgainActor>();

            // ActorOf will create the Actor
            // You can get a reference to the Actor using the ActorOf which returns an IActorRef
            UntypedActorSystem.ActorOf(whatsMyTypeAgainProps, "WhatsMyTypeAgain");

            // Alternatively you can use ActorSelection and a path to the Actor
            ActorSelection whatsMyTypeAgainActor = UntypedActorSystem.ActorSelection("/user/WhatsMyTypeAgain");

            // Tell is void
            whatsMyTypeAgainActor.Tell("I'm 30");

            // Ask with return a value (request response)
            var askTask = whatsMyTypeAgainActor.Ask<int>("Hey what's my age again?");
            Task.WaitAll(askTask);
            Console.WriteLine(askTask.Result);

            Console.ReadKey();
            UntypedActorSystem.Shutdown();
            UntypedActorSystem.AwaitTermination();
        }
开发者ID:DeonHeyns,项目名称:Exploring-Akka-Dot-NET,代码行数:30,代码来源:Program.cs

示例11: Main

        static void Main(string[] args)
        {
            // initialize MyActorSystem
            MyActorSystem = ActorSystem.Create("MyActorSystem");

            // time to make your first actors!
            Props consoleWriterProps = Props.Create<ConsoleWriterActor>();
            IActorRef consoleWriterActor = MyActorSystem.ActorOf(consoleWriterProps, "consoleWriterActor");

            Props tailCoordinatorProps = Props.Create(() => new TailCoordinatorActor());
            IActorRef tailCoordinatorActor = MyActorSystem.ActorOf(tailCoordinatorProps, "tailCoordinatorActor");

            Props fileValidatorActorProps = Props.Create(() => new FileValidatorActor(consoleWriterActor));
            IActorRef validationActor = MyActorSystem.ActorOf(fileValidatorActorProps, "validationActor");

            Props consoleReaderProps = Props.Create<ConsoleReaderActor>();
            IActorRef consoleReaderActor = MyActorSystem.ActorOf(consoleReaderProps, "consoleReaderActor");
            

            // tell console reader to begin
            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:phhlho,项目名称:akka.net-bootcamp,代码行数:25,代码来源:Program.cs

示例12: Main

        private static void Main(string[] args)
        {
            _actorSystem = ActorSystem.Create("OrderSystem");

              var prop = Props.Create<PlaceOrderHandlerActor>();
              var aref = _actorSystem.ActorOf(prop, "OrderHandlerActor");

              aref.Tell(
            new PlaceOrderMessage(
            "Shuhel",
            "Sylhet",
            new List<string>
            {
              "Chicken Tickka",
              "Chicken Chowmeen",
              "Pepsi"
            }));

              Console.ReadLine();

              Console.WriteLine("The system shutting down..");
              _actorSystem.Shutdown();
              _actorSystem.AwaitTermination();

              Console.WriteLine("The system is dead");

              Console.ReadLine();
        }
开发者ID:ahmedshuhel,项目名称:akkabakka,代码行数:28,代码来源:Program.cs

示例13: Main

        static void Main(string[] args)
        {
            // Akka prefers creation of objects via factories
            // this is due to the fact that internally Akka does a lot of system internally
            ReceiveActorSystem = ActorSystem.Create("ReceiveActorSystem");
            Console.WriteLine("Actor system created");

            // Akka uses the movie industry to name a few items
            // To create an Actor you use the Props class
            Props whatsMyTypeAgainProps = Props.Create<WhatsMyTypeAgainActor>();

            // ActorOf will create the Actor
            // You can get a reference to the Actor using the ActorOf which returns an IActorRef
            ReceiveActorSystem.ActorOf(whatsMyTypeAgainProps, "WhatsMyTypeAgain");

            // Alternatively you can use ActorSelection and a path to the Actor
            ActorSelection whatsMyTypeAgainActor = ReceiveActorSystem.ActorSelection("/user/WhatsMyTypeAgain");

            // Tell is void
            whatsMyTypeAgainActor.Tell("I'm 30");
            whatsMyTypeAgainActor.Tell("I'm 31"); // This message is ignored since the Actor's behavior has changed
            whatsMyTypeAgainActor.Tell(30);

            Console.ReadKey();
            ReceiveActorSystem.Shutdown();
            ReceiveActorSystem.AwaitTermination();

            Console.ReadKey();
        }
开发者ID:DeonHeyns,项目名称:Exploring-Akka-Dot-NET,代码行数:29,代码来源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            actorSystem = ActorSystem.Create("myActorSystem");
            Props props = Props.Create<RouteCoordinator>();
            var routerActor = actorSystem.ActorOf(props, "RouteCoordinator");

            routerActor.Tell(new Messages.RouteCoordinatorStart());

            actorSystem.AwaitTermination();
        }
开发者ID:saichaitanya88,项目名称:AkkaServer,代码行数:10,代码来源:Program.cs

示例15: Main

        private static void Main(string[] args)
        {
            MyActorSystem = ActorSystem.Create(nameof(MyActorSystem));
            var consoleWriterActor = MyActorSystem.ActorOf(Props.Create(() => new ConsoleWriterActor()));
            var consoleReaderActor =
                MyActorSystem.ActorOf(Props.Create(() => new ConsoleReaderActor(consoleWriterActor)));

            consoleReaderActor.Tell(ConsoleReaderActor.StartCommand);

            // blocks the main thread from exiting until the actor system is shut down
            MyActorSystem.AwaitTermination();
        }
开发者ID:iggywiggy,项目名称:akka-bootcamp,代码行数:12,代码来源:Program.cs


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