public void CouldUseDoExtensionMethodOnRange() { var count = 100; var sw = new Stopwatch(); sw.Start(); var sm = new SortedChunkedMap <DateTime, double>(); sm.IsSynchronized = true; var addTask = Task.Run(async() => { await Task.Delay(50); for (int i = 0; i < count; i++) { sm.Add(DateTime.UtcNow.Date.AddSeconds(i), i); } // signal data completion sm.Complete(); }); var cached = sm.After(DateTime.UtcNow.Date.AddSeconds(0), true); double sum = 0.0; var doTask = cached.Do((k, v) => { sum += v; Console.WriteLine($"{k} : {v}"); }); addTask.Wait(); doTask.Wait(1000); sw.Stop(); double expectedSum = 0.0; for (int i = 0; i < count; i++) { expectedSum += i; } Assert.AreEqual(expectedSum, sum); Console.WriteLine("Elapsed msec: {0}", sw.ElapsedMilliseconds - 50); Console.WriteLine("Ops: {0}", Math.Round(0.000001 * count * 1000.0 / (sw.ElapsedMilliseconds * 1.0), 2)); }