private void CleanUp()
{
lock (commitLock) {
if (IsClosed)
return;
// If no open transactions on the database, then clean up.
if (Database.TransactionFactory.OpenTransactions.Count == 0) {
var deleteList = StateStore.GetDeleteList().ToArray();
if (deleteList.Length > 0) {
int dropCount = 0;
for (int i = deleteList.Length - 1; i >= 0; --i) {
var tableName = deleteList[i].SourceName;
CloseTable(tableName, true);
}
for (int i = deleteList.Length - 1; i >= 0; --i) {
string tableName = deleteList[i].SourceName;
bool dropped = CloseAndDropTable(tableName);
// If we managed to drop the table, remove from the list.
if (dropped) {
StateStore.RemoveDeleteResource(tableName);
++dropCount;
}
}
// If we dropped a table, commit an update to the conglomerate state.
if (dropCount > 0)
StateStore.Flush();
}
}
}
}