Im using MVVM Light Messenger in my WPF application, and something is not working as expected.
my view-model registered with a token. im using 'long' objects as tokens. my code registered for example with the token 5, then sends request to a service. when the service replies it handles in my second view-model, which will then send the message with the same token.
When i debug and print the registration and sending of the messages it seems OK, but for some reason not all the messenger are received by the registered.
My registration and handling looks as follows:
private void registerTest()
{
long tokenId = getNextToken();
ExtraData data = new ExtraData();
Messenger.Default.Register<MyMsg>(this, tokenId, (m) => recieve(m,data));
}
private void receive(MyMsg m,ExtraData data)
{
Messenger.Default.Unregister<MyMsg>(this, m.tokenId);
}
My sending looks as follows:
private void sendTest(long tokenId)
{
Messenger.Default.Send(new MyMsg(tokenId), tokenId);
}
I always register with token X before its received in my sendTest, but for some reason, sometimes when sendTest(X) is called, its not received.
Anyone has any idea whats going on?