Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transactionThreadId"></param>
        public void UnregisterTransaction(int transactionThreadId)
        {
            TransactionUnit transactionUnit = this.GetTransactionUnit(transactionThreadId);
            Exception       exc             = null;

            if (transactionUnit != null)
            {
                _sync_transactions.EnterWriteLock();
                try
                {
                    this._transactions.Remove(transactionUnit.Transaction.ManagedThreadId);
                    transactionUnit.Dispose();
                }
                catch (System.Exception ex)
                {
                    exc = ex;
                }
                finally
                {
                    _sync_transactions.ExitWriteLock();
                }
            }

            //letting other threads, which tried to register tables for modification and were blocked, to re-try the operation.
            //mreWriteTransactionLock.Set();
            ThreadsGator.OpenGate();

            if (exc != null)
            {
                throw exc;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Is called by the engine on Dispose.
        /// </summary>
        public void UnregisterAllTransactions()
        {
            Exception exc = null;

            _sync_transactions.EnterWriteLock();
            try
            {
                foreach (var transactionUnit in _transactions.Values)
                {
                    try
                    {
                        transactionUnit.Dispose();
                    }
                    catch (Exception ex)
                    {
                        if (exc == null)
                        {
                            exc = ex;
                        }
                    }
                }

                this._transactions.Clear();
            }
            catch (System.Exception ex)
            {
                if (exc == null)
                {
                    exc = ex;
                }
            }
            finally
            {
                _sync_transactions.ExitWriteLock();

                //lettign other threads, which tried to register tables for modification and were blocked, to re-try the operation.
                //mreWriteTransactionLock.Set();
                ThreadsGator.OpenGate();

                //No need here
                //////if (exc != null)
                //////    throw exc;
            }
        }