ReactiveUI messagebus -


i'm testing reactiveui, seems nice.

however, bit puzzled messagebus.

sample code :

var bus = new messagebus(); int result = -1;  bus.listen<int>().subscribe(x => result = x); bus.sendmessage(42); 

it work when calling assert statement, in standard wpf application result value never updated. due scheduler implementation, it's not quite clear me yet.

any hint welcome.

the result eventually updated (the same calling dispatcher.begininvoke), not immediately. default, rxui schedules things differently in unit test runner make easier write unit tests - that's why see warning in unit test runner output.

if instead like:

var bus = new messagebus();  bus.listen<int>().subscribe(x => messagebox.show("the answer " + x)); bus.sendmessage(42); 

you see message box (if not, it's bug!).

why messagebus deferred? makes easier write async code, since can sendmessage other threads without seeing wpf's dreaded invalidoperationexception due accessing objects on wrong thread.


Comments