C
C#•2mo ago
GooBad

MVVM Toolkit Messenger - RequestMessage

I have no idea why one of the methods is never executed... take a look at this vs Messenger
C#
public class AsyncRLoginMsgReq : AsyncRequestMessage<bool>{};
C#
public class AsyncRLoginMsgReq : AsyncRequestMessage<bool>{};
C#
public class LoginRequestProcessor{
public readonly IMessenger Messenger;

public LoginRequestProcessor(IMessenger messenger) {
Messenger = messenger;
}

public void RegisterAll() {
// \/
Messenger.Register<AsyncRLoginMsgReq>(this, (r, m) =>
{
// NEVER EXECUTED
m.Reply(Task.FromResult(true));
});
// \/
Messenger.Register<AsyncRLoginMsgReq>(Messenger, (r, m) =>
{
// EXECUTED
m.Reply(Task.FromResult(true));
});
}

}
C#
public class LoginRequestProcessor{
public readonly IMessenger Messenger;

public LoginRequestProcessor(IMessenger messenger) {
Messenger = messenger;
}

public void RegisterAll() {
// \/
Messenger.Register<AsyncRLoginMsgReq>(this, (r, m) =>
{
// NEVER EXECUTED
m.Reply(Task.FromResult(true));
});
// \/
Messenger.Register<AsyncRLoginMsgReq>(Messenger, (r, m) =>
{
// EXECUTED
m.Reply(Task.FromResult(true));
});
}

}
C#
// some other class
var r = await _messenger.Send(new AsyncRLoginMsgReq());
C#
// some other class
var r = await _messenger.Send(new AsyncRLoginMsgReq());
1 Reply
GooBad
GooBadOP•2mo ago
And I don't mean that both should be executed, it's just that one of them won't ever execute even if its the only one registered. It's because this is just disposed at some point before... 😄
Want results from more Discord servers?
Add your server