public void Start(Plugin p) { // p.ForEach(r => { if (r is Record) ++totalRecordCount; }); // p.While(r => { if (r is Record) { UpdateProgress(); return Process((Record)r); } }); var recordList = new List<Record>(); p.ForEach( r => { if (r is Record) { recordList.Add((Record)r); } }); this.totalRecordCount = recordList.Count; foreach (var kvp in recordList.ToLookup((a) => a.Name)) { if (!this.Process(kvp.Key, kvp.ToArray())) { return; } } }