akka.net is there a a way to get or create actor

主宰稳场 提交于 2019-12-01 19:15:26

You can check if current actor has a child with provided name by using Context.Child(actorName) method. It will return actor ref of the target actor if it exists or ActorRefs.Nobody if there is no such actor.

Code in your case could look like:

var child = Context.Child(actorName);
if (Equals(child, ActorRefs.Nobody))
    child = Context.ActorOf(MyActor.Props(message), actorName);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!