"景先生毕设|www.jxszl.com

C# ActorSystem类代码示例

2023-12-29 17:00编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中ActorSystem类的典型用法代码示例。如果您正苦于以下问题:C# ActorSystem类的具体用法?C# ActorSystem怎么用?C# ActorSystem使用的例子? 这里精选的类代码示例或许可以为您提供帮助。 示例1: Main static void Main(string[] args) { // initialize MyActorSystem MyActorSystem = ActorSystem.Create("MyActorSystem"); // time to make your first actors! var consoleWriterActor = MyActorSystem.ActorOf(Props.Create(), "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(); }
原文链接:http://www.jxszl.com/biancheng/C/556478.html