Наследование: IEnlistmentNotificationInternal
Пример #1
0
        protected static void PoolableInDoubt(object state)
        {
            VolatileDemultiplexer demultiplexer = (VolatileDemultiplexer)state;
            bool lockTaken = false;

            try
            {
                Monitor.TryEnter(demultiplexer.transaction, 250, ref lockTaken);
                if (lockTaken)
                {
                    demultiplexer.InternalInDoubt();
                }
                else if (!ThreadPool.QueueUserWorkItem(InDoubtCallback, demultiplexer))
                {
                    throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("UnexpectedFailureOfThreadPool"), null);
                }
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(demultiplexer.transaction);
                }
            }
        }
Пример #2
0
        protected static void PoolablePrepare(object state)
        {
            VolatileDemultiplexer demux = (VolatileDemultiplexer)state;

            // Don't block an enlistment thread (or a thread pool thread).  So
            // try to get the transaction lock but if unsuccessfull give up and
            // queue this operation to try again later.
            bool tookLock = false;

            try
            {
                Monitor.TryEnter(demux._transaction, 250, ref tookLock);
                if (tookLock)
                {
                    demux.InternalPrepare();
                }
                else
                {
                    if (!ThreadPool.QueueUserWorkItem(PrepareCallback, demux))
                    {
                        throw TransactionException.CreateInvalidOperationException(
                                  SR.TraceSourceLtm,
                                  SR.UnexpectedFailureOfThreadPool,
                                  null
                                  );
                    }
                }
            }
            finally
            {
                if (tookLock)
                {
                    Monitor.Exit(demux._transaction);
                }
            }
        }
 public override void Rollback(IPromotedEnlistment en)
 {
     base.oletxEnlistment = en;
     VolatileDemultiplexer.PoolableRollback(this);
 }
 public override void Prepare(IPromotedEnlistment en)
 {
     base.preparingEnlistment = en;
     VolatileDemultiplexer.PoolablePrepare(this);
 }
 public override void InDoubt(IPromotedEnlistment en)
 {
     base.oletxEnlistment = en;
     VolatileDemultiplexer.PoolableInDoubt(this);
 }