3

I'm trying to implement messaging between my ViewModels My Proof of Concept Code is the following:

RxApp.MessageBus.Listen<int>("test")
    .Subscribe(i => MessageBox.Show(i.ToString()));    

RxApp.MessageBus.SendMessage<int>(42, "test");

My unit Tests run successfully so I thought it might be a Scheduling problem. I manually set the Scheduler: RxApp.DeferredScheduler = DispatcherScheduler.Instance;

but it was set to the right Instance anyway so as expected, no change. I can register for Messages. I just never receive any :/ Using an empty message contract does not change anything either.

I tried on both the Emulator and a Device (Mango SDK Refresh / Mango Build 7712)

I hope someone here can help me :) Any hints are very much appreciated.

skaffman
  • 398,947
  • 96
  • 818
  • 769

2 Answers2

3

I suspect this is a MessageBus bug - who writes this crap, anyways?

** I'll look into it :)

Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • I don't mean to nag, but i'm kind of on a deadline here ;) I would love to use the MessageBus, but maybe I need to find a replacement... Regardless, i'd like to help in finding a solution for the MessageBus if I can :) – rollingthunder Aug 17 '11 at 15:09
  • Even if I fix it, making a release is a fairly time-consuming affair. MessageBus is actually just a single CS file, you could copy it and change it to do what you want (you can even name your implementation MessageBus2 then set RxApp.MessageBus) – Ana Betts Aug 18 '11 at 18:35
  • I don't mean to leave you in the lurch, but just from a practical perspective, this is the quickest way for you to get unstuck – Ana Betts Aug 18 '11 at 20:47
  • Against my expectations, it turned out to be within my powers to solve ;) I sent you a pull request on Github with the fixes. – rollingthunder Aug 23 '11 at 14:11
-1

My mistake, for assuming it was something non-trivial to do with the Scheduler :)

The problem was, that the Tuple class in use as a Dictionary key on WP7/SL does not implement a useful Equals() override.

The Dictionary never returned any matches when looking up the registered Subjects.

GetHashCode() should also be replaced with a custom implementation.