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