Search code examples
c#mefsystem.reactiveeventaggregator

Issues with Event Aggregator using Reactive Extensions


To link up my MEF application, I'm using the event aggregator found here. Its been perfect for distributing data into modules that actually need it.

I'm getting more into using the reactive extensions and I've been trying to do the following:

eventSubscription = MainApp.Events.GetEvent<UDPMessageIn>()
                                  .BufferWithTime(TimeSpan.FromSeconds(1))
                                  .Subscribe(x => 
                                       { 
                                           // do something here...
                                       });

However, the event aggregator appears to hang in the Publish method on:

((ISubject<TEvent>)subject).OnNext(sampleEvent);

I'm guessing that there's something about the design of either system.reactive or the aggregator that I don't fully understand. Anybody got any ideas?


Solution

  • It turned out to be a threading issue that was unrelated to Rx or the event aggregator.

    Changing one of my UI Invokes to BeginInvoke stopped it from hanging and this got me looking at the right bits of code...