protected override void PerformSave() { Dictionary <long, InventorySaveData> toSave; List <long> toDelete; lock (this) { toSave = _saveInventories; _saveInventories = new Dictionary <long, InventorySaveData>(); toDelete = _deleteInventories; _deleteInventories = new List <long>(); } Saver.PerformSave(toSave.Values); Saver.DeleteItems(toDelete.Select(item => GetFileForInventory(item))); }
protected override void PerformSave() { List <InventorySaveData> itemsToSave; List <string> itemsToDelete; lock (this) { itemsToSave = _itemsToSave; _itemsToSave = new List <InventorySaveData>(); itemsToDelete = _itemsToDelete; _itemsToDelete = new List <string>(); } Saver.SaveItems(itemsToSave); Saver.DeleteItems(itemsToDelete); }