I may be doing something incorrect, but it is not apparent. I have the following code:
namespace test
{
class Program
{
static void Main(string[] args)
{
using (var system = ActorSystem.Create("MySystem"))
{
var testPassRetriever = system.ActorOf<PrintActor>();
var task = testPassRetriever.Ask<PrintActorMsg>(new PrintActorMsg());
// prevent the application from exiting before message is handled
task.Wait();
Console.WriteLine("Finished.");
Console.ReadLine();
}
}
}
class PrintActorMsg{}
class PrintActor : ReceiveActor
{
public PrintActor()
{
Receive<PrintActorMsg>(msg => Console.WriteLine("foo"));
}
}
}// namespace test
The issue is that the Task returned by Ask never completes. Its status stays in the Waiting for Activation state. "Foo" does get printed on the command line so I know the actor is processing the Print message. Is there something else I am supposed to do in the overridden actor PrintMsg to mark the task completed?
You use the ask pattern, but never send a message back. The ask task will only be completed when a message is received from the actor. The (sometimes advised) tell or fire-and-forget pattern doesn't do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With