コード例 #1
0
ファイル: Transaction.cs プロジェクト: ykonoval88/HomeTask4
        public static bool BeginTransaction(this HashTableWrapper hashTable)
        {
            if (!Monitor.TryEnter(hashTable))
            {
                throw new AccessViolationException("The same table already locked!");
            }

            return(true);
        }
コード例 #2
0
ファイル: Transaction.cs プロジェクト: ykonoval88/HomeTask4
        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);
        }
コード例 #3
0
ファイル: Transaction.cs プロジェクト: ykonoval88/HomeTask4
 public static void CommitTransaction(this HashTableWrapper hashTable)
 {
     hashTable.TransactionJournalAdd.Clear();
     hashTable.TransactionJournalRemove.Clear();
     Monitor.Exit(hashTable);
 }