Windows Forms Message.Hub

0

Working with Windows Forms, Visual Studio 2015, Message.Hub

I have time working with this event subscribe without problems, now I have the need to subscribe an event and it is executed before the Load event but it is not happening that, on the contrary the event is never executed.

I show the code that I occupy.

    private readonly ISaUsuario _saUsuario = CompositionRoot.Resolve<SaUsuario>();
    private readonly MessageHub _hub = MessageHub.Instance;

    public MDI()
    {
        _hub.Subscribe<BusquedaSelected>(OnUsuarioSelected);
        InitializeComponent();

    }

    private void OnUsuarioSelected(BusquedaSelected obj)
    {
        if (!String.IsNullOrEmpty(obj.Valor))
        {
            var entity = _saUsuario.Single(x => x.User == obj.Valor);
            if (entity != null)
            {
                picFoto.Image = entity.Foto == null
                    ? ImageHelper.ObtenerImagenNoDisponible(AsignacionTablasType.Usuario)
                    : ImageHelper.ByteArrayToImage(entity.Foto);
                lblUsuario.Text = entity.Nombre;
            }
        }
    }

    private void MDI_Load(object sender, EventArgs e)
    {


    }

I hope you can help me. I need the event OnUsuarioSelected to be executed before the Load ()

Easy.MessageHub

Cleaner Pub-Sub using the Event Aggregator Pattern

    
asked by Pedro Ávila 18.08.2018 в 22:17
source

0 answers