I have an observable collection that is filled from a load of events. I want to take information from the EventArg, group it by name and then select the maximum date for each name. I have tried this :
_subscription = Observable
.FromEventPattern<NewLoanEventHandler, NewLoanEventArgs>(
h => loan.NewLoanEvent += h,
h => loan.NewLoanEvent -= h)
.Select(a => a.EventArgs.Counterpatry)
.GroupBy(c => c.Name)
.SelectMany(grp => grp.Max( c => c.MaturityDate ).Select( maturity => new {grp.Key, maturity}) )
.Subscribe(
i => Console.WriteLine("{0} --> {1}", i.Key, i.maturity),
Console.WriteLine,
() => Console.WriteLine("completed")
);
I think it might do what I want, but the subscription never completes : I never get the complete message and I don't get any output. That is, I suspect, because the Observable is still waiting for more events. How do I tell it to stop waiting and give me my output?