Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda