We've got a client calling off to a TIBCO EMS queue and are wiring up the events like this:
var msgConsumer = _session.CreateConsumer(responseQueue); var response = Observable.FromEvent<EMSMessageHandler,EMSMessageEventArgs> (h => msgConsumer.MessageHandler += h, h => msgConsumer.MessageHandler -= h) .Where(arg => arg.Message.CorrelationID == message.MessageID);
When I call response.Subscribe(...)
I get System.ArgumentException "Error binding to target method."
I can make it work with Observable.FromEventPattern<EMSMessageEventArgs>(msgConsumer, "MessageHandler")
but then it's got the event as a string and just not as clean.
Also I have IObservable<EventPattern<EMSMessageEventArgs>>
rather than IObservable<EMSMessageEventArgs>
What I'd like to understand is: when should I use FromEvent
over FromEventPattern
? It seems a bit trial and error.
"Use FromEvent for events structurally don't look like a .NET event pattern (i.e. not based on sender, event args), and use FromEventPattern for the pattern-based ones." - Bart De Smet (Rx team)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With