System.Transactions.VolatileEnlistmentSPC.EnterState C# (CSharp) Method

EnterState() private method

private EnterState ( InternalEnlistment enlistment ) : void
enlistment InternalEnlistment
return void
        internal override void EnterState(InternalEnlistment enlistment)
        {
            bool spcCommitted = false;
            // Set the enlistment state
            enlistment.State = this;

            // Send Single Phase Commit to the enlistment
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.EnlistmentStatus(enlistment, NotificationCall.SinglePhaseCommit);
            }

            Monitor.Exit(enlistment.Transaction);
            try // Don't hold this lock while calling into the application code.
            {
                enlistment.SinglePhaseNotification.SinglePhaseCommit(enlistment.SinglePhaseEnlistment);
                spcCommitted = true;
            }
            finally
            {
                if (!spcCommitted)
                {
                    //If we have an exception thrown in SPC, we don't know the if the enlistment is committed or not
                    //reply indoubt
                    enlistment.SinglePhaseEnlistment.InDoubt();
                }
                Monitor.Enter(enlistment.Transaction);
            }
        }

Usage Example

 internal override void ChangeStateSinglePhaseCommit(InternalEnlistment enlistment)
 {
     VolatileEnlistmentSPC.EnterState(enlistment);
 }