public void Commit()
{
TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
if (etwLog.IsEnabled())
{
etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
etwLog.TransactionCommit(this, "CommittableTransaction");
}
if (Disposed)
{
throw new ObjectDisposedException(nameof(CommittableTransaction));
}
lock (_internalTransaction)
{
if (_complete)
{
throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
}
_internalTransaction.State.BeginCommit(_internalTransaction, false, null, null);
// now that commit has started wait for the monitor on the transaction to know
// if the transaction is done.
do
{
if (_internalTransaction.State.IsCompleted(_internalTransaction))
{
break;
}
} while (Monitor.Wait(_internalTransaction));
_internalTransaction.State.EndCommit(_internalTransaction);
}
if (etwLog.IsEnabled())
{
etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
}
}