Esempio n. 1
0
        public static bool BeginTransaction(this HashTableWrapper hashTable)
        {
            if (!Monitor.TryEnter(hashTable))
            {
                throw new AccessViolationException("The same table already locked!");
            }

            return(true);
        }
Esempio n. 2
0
        public static void RollbackTransaction(this HashTableWrapper hashTable)
        {
            foreach (var journalItem in hashTable.TransactionJournalAdd)
            {
                hashTable.Remove(journalItem);
            }

            foreach (var journalItem in hashTable.TransactionJournalRemove)
            {
                hashTable.Add(journalItem);
            }
            Monitor.Exit(hashTable);
        }
Esempio n. 3
0
 public static void CommitTransaction(this HashTableWrapper hashTable)
 {
     hashTable.TransactionJournalAdd.Clear();
     hashTable.TransactionJournalRemove.Clear();
     Monitor.Exit(hashTable);
 }