As I know, all operations in Akka.Net are asynchronous, and Context.Stop()
simply sends a Stop
message to the actor. That means, actor will be alive for some time before it completely shuts down.
And if I'll call Context.Child()
right after Context.Stop()
with the name of the actor I just stopped, I will get the same actor.
Here is the example code
var actor = context.Child(actorName);
if (actor.Equals(ActorRefs.Nobody))
{
actor = CreateNewActor();
}
Context.Stop(actor)
actor = context.Child(actorName);
// what do we get here, same actor or ActorRefs.Nobody ?
My application creates actors to process events from terminals. Each time new terminal connected, I create new actor by calling Context.Child()
using terminal name. When terminal disconnects, I stop the actor.
Problem is that some times I receive Connect message right after Disconnect for same terminal, and as result I get actor that's going be stopped. Is there any way to check that actor received Stop message and will be stopped soon?