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); } } }
protected static void PoolableInDoubt(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.InternalInDoubt(); } else { if (!ThreadPool.QueueUserWorkItem(InDoubtCallback, demux)) { throw TransactionException.CreateInvalidOperationException( SR.TraceSourceLtm, SR.UnexpectedFailureOfThreadPool, null ); } } } finally { if (tookLock) { Monitor.Exit(demux._transaction); } } }