public int FindAndDeleteAllTemplated() { var settlements2Delete = new List <Settlement>(); //settlements foreach (var settlement in Settlements.It) { if (settlement.CreationType == CreationType.TemplateCreated) { settlements2Delete.Add(settlement); } } var totalCount = settlements2Delete.Count; foreach (var dbBase in settlements2Delete) { Settlements.DeleteItemNoWait(dbBase); } //houses var housesToDelete = new List <House>(); foreach (var house in Houses.It) { if (house.CreationType == CreationType.TemplateCreated) { housesToDelete.Add(house); } } totalCount += housesToDelete.Count; var t2 = new Thread(() => { foreach (var dbBase in housesToDelete) { Houses.DeleteItemNoWait(dbBase); } }); t2.Start(); t2.Join(); //modularhosueholds var mhhToDelete = new List <ModularHousehold>(); foreach (var household in ModularHouseholds.It) { if (household.CreationType == CreationType.TemplateCreated) { mhhToDelete.Add(household); } } totalCount += mhhToDelete.Count; var t3 = new Thread(() => { foreach (var dbBase in mhhToDelete) { ModularHouseholds.DeleteItemNoWait(dbBase); } }); t3.Start(); t3.Join(); //vacations var vacationsToDelete = new List <Vacation>(); foreach (var vacation in Vacations.It) { if (vacation.CreationType == CreationType.TemplateCreated) { vacationsToDelete.Add(vacation); } } totalCount += mhhToDelete.Count; var t4 = new Thread(() => { foreach (var dbBase in vacationsToDelete) { Vacations.DeleteItemNoWait(dbBase); } }); t4.Start(); t4.Join(); Logger.Info("Finished deleting all templated items."); return(totalCount); }