private void Aggregate(IObservable <LogEvent> events)
        {
            Guid g = Guid.NewGuid();

            Console.WriteLine(g + " opened at " + DateTime.Now);
            List <LogEvent> allEvents = new List <LogEvent>();

            events.ObserveOn(TaskPoolScheduler.Default).Subscribe(
                evt => allEvents.Add(evt),
                () =>
            {
                Console.WriteLine(g + " closed at " + DateTime.Now);
                var gr = GroupCounters(allEvents);
                _aggregationCompleteSubject.OnNext(gr.Select(gouppedValues =>
                {
                    AggregatedValue result =
                        new AggregatedValue(
                            gouppedValues.Key,
                            _aggregationOperation.Do(
                                gouppedValues.ToList()));
                    Console.WriteLine(DateTime.Now + " Aggregated on thread #" + Thread.CurrentThread.ManagedThreadId);
                    return(result);
                }).ToList());
                Console.WriteLine(g + " Finished on thread #" + Thread.CurrentThread.ManagedThreadId + "\r\n" + string.Join("\r\n", allEvents));
            });
        }
 private void Aggregate(IObservable<LogEvent> events)
 {
     Guid g = Guid.NewGuid();
     Console.WriteLine(g + " opened at "+ DateTime.Now);
     List<LogEvent> allEvents = new List<LogEvent>();
     events.ObserveOn(TaskPoolScheduler.Default).Subscribe(
         evt => allEvents.Add(evt),
         () =>
     {
         Console.WriteLine(g + " closed at " + DateTime.Now);
         var gr = GroupCounters(allEvents);
         _aggregationCompleteSubject.OnNext(gr.Select(gouppedValues =>
         {
             AggregatedValue result =
                 new AggregatedValue(
                     gouppedValues.Key,
                     _aggregationOperation.Do(
                         gouppedValues.ToList()));
             Console.WriteLine(DateTime.Now + " Aggregated on thread #" + Thread.CurrentThread.ManagedThreadId);
             return result;
         }).ToList());
         Console.WriteLine(g + " Finished on thread #" + Thread.CurrentThread.ManagedThreadId+"\r\n"+string.Join("\r\n",allEvents));
     });
 }