Akka.NET 介绍
Akka.NET 是 Akka 的 .NET
开源实现。用于构建强大的并发和分布式应用。Akka 是一个用 Scala 编写的库,用于简化编写容错的、高可伸缩性的 Java 和 Scala 的
Actor 模型应用。
示例代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Akka; using Akka.Actor; namespace ConsoleApplication11 { public class Greet { public Greet(string who) { Who = who; } public string Who { get;private set; } } public class GreetingActor : ReceiveActor { public GreetingActor() { Receive<Greet>(greet => Console.WriteLine("Hello {0}", greet.Who)); } } class Program { static void Main(string[] args) { //create a new actor system (a container for your actors) var system = ActorSystem.Create("MySystem"); //create your actor and get a reference to it. //this will be an "ActorRef", which is not a //reference to the actual actor instance //but rather a client or proxy to it var greeter = system.ActorOf<GreetingActor>("greeter"); //send a message to the actor greeter.Tell(new Greet("World")); //this prevents the app from exiting //Before the async work is done Console.ReadLine(); } } }
Akka.NET 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。