Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
How to receive message from an actor in non actor class

I'm using an actor system to calculate some data, and then I want it to return the result from not originally asked actor endpoint to my non actor oriented program. I tried using Ask or Ask<> with await or Result but it didn't help either. This is a simplified example of what I want to achieve:

class Program
{
    public static ActorSystem actorSystem;
    static async Task Main(string[] args)
    {
        actorSystem = ActorSystem.Create("ActorSystem");
        var mainActor = actorSystem.ActorOf(Props.Create(() => new MainActor()), "main");
        var actorAnswer = await mainActor.Ask<object[]>(new Start(true));
        //Some operations using actorAnswer from actor ...
    }
}

And simplified MainActor:

class MainActor : ReceiveActor
{
    public MainActor()
    {
        Receive<Start>(m =>
        {
            _commanderActor.Tell(new SomeMessage());
        });
        Receive<IEnumerable<int[]>>(m => 
        {
            if (condition)
            {                                                     
                Sender.Tell(new object[] {x, y});
            }
            else
            {
                _commanderActor.Tell(new SomeMessage());
            }

        });
    }
}
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!