void Main() { using (var g = new Group ("stuff", t => t.DumpHere ($"Test finished in {t.Elapsed}"))) { g.DumpHere ("foo"); g.DumpHere ("bar"); g.DumpHere ("array".ToCharArray()); } } class Group : IDisposable { DumpContainer _dc; ArrayList _items = new ArrayList(); Stopwatch _timer; Action _onCompletion; public TimeSpan Elapsed => _timer.Elapsed; public Group (string heading, Action onCompletion = null) { _dc = new DumpContainer().Dump (heading); _onCompletion = onCompletion; _timer = Stopwatch.StartNew(); } public T DumpHere (T item) { _items.Add (item); _dc.Content = Util.VerticalRun (_items); return item; } public void Dispose() { _timer.Stop(); if (_onCompletion != null) _onCompletion (this); } }